Deep linking and back button

Hey!

Since there is no server side rendering, I can only run part of the app on anvil. I’d like to link to and embed certain screens, but there’s no way to load a screen via a url that I can find. Ie: http://foo.anvilapp.net/fooForm etc.

Also, the back button doesn’t work. This could be worked around by doing a pushstate on each form load if deep linking was present.

Thanks!

1 Like

You can, sort of, using get_url_hash() (see here : https://anvil.works/doc/#-div-id-anvil_modules-anvil-modules-div-)

In brief, you can fetch everything after the # symbol in a url and route accordingly. So in your example, this URL :

http://foo.anvilapp.net/?#fooForm

you could do this in your main form :

required_page = get_url_hash()
if required_page == "fooForm":
    open_form("fooForm")

making your main page act just as a router.

(whilst you could obviously do open_form(required_form) I can’t recommend blindly doing anything sent in from ‘outside’)

Not out of the box, no. It might be possible to integrate a 3rd party library to do so, but you’d be going very off piste and into unstable territory in my opinion.

oh sweet! ok, so you can route requests to forms, perfect :slight_smile:

I wouldn’t worry about manipulating the history object messing up an anvil app. It’s pretty easy to use.

Thank you!