Search code examples
svelteroutify

Make Routify use #hash


I'm using this Svelte router - https://routify.dev/

It works fine but I can't get it to work with hashes instead of regular paths.

In the examples I've changed the nav to ["./#index", "Home"], and it changes the address bar but the router no longer reacts to the change.

I'm very new to Svelte and Routify so I wouldn't even know where to start from. There isn't much in the Docs either. Thanks!


Solution

  • As shown in this post you just need to change your router component tag to <Router config={{useHash: true}} {routes} /> in the src/App.svelte file.

    All of the links that use the url helper will automatically get the hash.