Skip to content

Instantly share code, notes, and snippets.

@Wolfr
Last active June 5, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wolfr/3a76cca35f4bf27e7730435ffa6b8610 to your computer and use it in GitHub Desktop.
Save Wolfr/3a76cca35f4bf27e7730435ffa6b8610 to your computer and use it in GitHub Desktop.

Routify updates + Frequently asked questions

The past month we've seen three new Routify feature releases:

  • 1.8 (beta)
    • Support for service workers
    • Support for prefetching
    • Support disabling prerendering with prerender=false
    • Support plugins
    • Added new $isChangingPage helper
    • Various bug fixes
  • 1.7: Better support for configs through package.json and environment variables (.env)
  • 1.6: Added afterPageLoad hook (see documentation)

Next to this, we are continuing to improve the documentation. We're thinking about a new layout that will make it easier to find things.

As the framework gets more popular, we get more and more questions on our Discord channel (join us!).

Some of these will eventually be added to the docs on a dedicated FAQ page when deemed relevant for everyone. In FAQ this page it already in progress, but in order to keep us sane, we are already posting this content as a blog post so we can link to it easily.

What is the difference between Routify and Sapper?

This is a tough one to answer. Routify is a router. Routify starter is a template that provides much more than routing.

The Routify website - the very website you're looking at - talks about much more than routing alone. It is clear our ambitions are bigger than being a simple file-based router. These ambitions are coming to fruition in a project called Roxi. If you are eager to learn, join the discussion in the #roxi channel on Discord.

I looked at the helpers but I am missing [specific helper question]?

There are a few helper functions that were added in 1.7 and 1.8 that need some better documentation. In lieu of finished docs, we provide some information here.

  • $redirect() functions the same as $goto(), but uses replacestate instead of pushstate (the original page doesn't get added to browser history)
  • $isChangingPage` ...

How do I use Routify with Electron?

  • Try the svelte-app-electron template from @legionofone
  • Electron doesn't detect changes in node_modules. To get around that, we can export the generated files to a folder in the project. The command routify --routify-dir routify will change the directory Routify uses for its files. Remember to import your routes.js from this folder.

Why does my app disappear when I refresh?

Your server isn't forwarding requests to Routify. Make sure that you redirect 404s to your entrypoint. Usually /index.html or /__app.html.

Can I use Routify without SSR, dynamic imports, static exports, etc.?

Yes. If you're using the starter template, these features are enabled by default, but can be disabled. Please note that these features are not mutually exclusive and you still get a full-fledged SPA when they're enabled.

What's the difference between SSR and prerender/static export?

SSR (Server side Rendering) is done in realtime and is useful for pages with dynamic content, like a news feed. Prerendering/static export is done when building the app. Prerendered pages are great for pages that don't rely on APIs.

@jakobrosenberg
Copy link

$isChangingPage is a store which returns true while navigation is in progress. Ie, when the URL changes the store changes to true and once all the layouts and the page has been loaded on the new page, it changes to false. It's primarily intended for spinners and other loaders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment