voyager icon indicating copy to clipboard operation
voyager copied to clipboard

How can i handle web browser history in web platform

Open sunildhiman90 opened this issue 1 year ago • 5 comments

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

sunildhiman90 avatar Jun 14 '23 07:06 sunildhiman90

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.

programadorthi avatar Jun 17 '23 15:06 programadorthi

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.

sunildhiman90 avatar Jun 17 '23 17:06 sunildhiman90

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

ahmedsalemelzeiny avatar Aug 23 '23 13:08 ahmedsalemelzeiny

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.

Syer10 avatar Aug 23 '23 13:08 Syer10

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

eygraber avatar Apr 12 '24 05:04 eygraber