adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.31k stars 109 forks source link

How can i handle web browser history in web platform #161

Open sunildhiman90 opened 11 months ago

sunildhiman90 commented 11 months ago

Hi,

With voyager navigation, i cant see any option to interact with browser history or url. For example, controlling the browser history back and forward button and changing the content according to that, And during navigation, changing the url in browser. And also if we change url directly in the browser, how to handle that case with tab navigators and navigators in voyager.

Thanks

programadorthi commented 11 months ago

Without a routing system this will not be easy to be handled on Voyager. Browser stack is to limitaded to store all voyager stack info and all browser history info is path based. So, I'm trying bring Kotlin Routing to Voyager here and I have a little experiment using browser APIs here that is not complete yet.

sunildhiman90 commented 11 months ago

Great, yes, then it will be possible. waiting for that. I was also looking into ktor routing to manually do all this stuff with voyager navigator. But thanx to you, now we can probably get this in voyager very soon i think.

ahmedsalemelzeiny commented 9 months ago

@programadorthi Do you have any updates about these changes or when they will be available?

Syer10 commented 9 months ago

I needed it so I added it to my fork https://github.com/Syer10/voyager

You can reference https://github.com/programadorthi/kotlin-routing/tree/main/samples/kotlin-js-sample/src/jsMain/kotlin for adding support to control browser history, its not in the library but its not difficult to port the sample to Voyager-routing.

eygraber commented 1 month ago

If you're looking for inspiration, I recently implemented it in my (non voyager) library - WasmHistory.kt