How do you create routes with optional parameters in Sapper?

Optional parameters aren't yet supported, but you can almost fake it with 'rest routes' (which I've just realised aren't yet documented ‍♂️) — routes/[...parts]/foo.svelte would render foo.svelte with a page.params.parts array that contained the preceding segments.

Unfortunately that doesn't match /foo, which it arguably should. I've raised an issue: https://github.com/sveltejs/sapper/issues/765

Tags:

Svelte

Sapper