Hi Guys, I have a small doubt around the multiplat...
# multiplatform
k
Hi Guys, I have a small doubt around the multiplatform web support, so I was working on a multiplatform project that also includes compose multiplatform, and as we know that using compose multiplatform we can create web applications(not pages), which means there is no separate page with a unique address, so is there a way I can solve this problem where I can create pages that have unique addresses
d
I guess depending on your navigation implementation you can set the url manually via js. Also you can get the url when the user enters the page and navigate to the respective page in your app accordingly.
k
Thanks @Daniel Weidensdörfer, I mostly work on mobile apps, and have very less knowledge about web, it'll be great if you can just share some resources for this implementation
d
Well I haven't implemented it myself. I would take a look at https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-navigation-routing.html. In combination with https://kotlinlang.org/docs/wasm-js-interop.html#kotlin-functions-with-javascript-code, assuming you're using WASM for the web part. Then just figure out how to get and set the current url in js and sync in somehow with the compose navigation lib. Just some ideas, I haven't used the built in navigation yet.
k
thanks a lot, I will go through it
a
You can use
window.location.pathname
to get the URL Library Decompose fully support deeplinking, paths, web history https://arkivanov.github.io/Decompose/navigation/stack/browser-history/ Check their compose sample by running
./gradlew :sample:app-js-compose:jsRun
k
ok let me try this out
Hey @Andraz, I used your solution it worked like a charm, but I have a doubt, does decompose's WebHistoryController supports dynamic urls, let's say my web app has 2 pages with urls, •
{host}/items
{host}/item_details/{item_id}
So, the first page has list of items and the second page opens on the click of any item card, and shows the details of that particular item, so I want to keep the path of second page like this
{host}/item_details/{item_id}
where
item_id
represents the id of that particular item
a
yes, I have the same example in my application. Configure
getPathForConfig
getConfigForPath
methods I just had to add one line to
index.html
to support 2+ path levels
Copy code
<head>
    <base href="/">
</head>
Found about it here
k
Thanks @Andraz for your support, now i'm able to support 2+ path levels for my for my web app
🙌 1