An advanced Svelte 3 router.
Routve is an advanced non-official Svelte 3 router like vue-router
. Under the hood it uses page.js.
Alright there are so many router libraries and components for Svelte. So why would you use Routve?
Simply, Routve is super simple - easy to use, always up-to-date, maintained, stable and advanced. It has already used in production, and some development projects. Routve supports advanced and complex features such as route managing, navigation guards, page load handling, automatic links, hashbang, nested routing, and most importantly code splitting (aka. dynamic component import).
When we first created Routve, there was no properly enough advanced router library which especially supports code splitting and nested routing. We believed we can create only one truly advanced enough router library for Svelte. Now, we are introducing you: Routve with further features.
Routve supports these features for now:
/login
/register
, without hash - ideal for SPA and SSR - default
index.html#!/login
index.html#!/register
, ideal for static SPA<Router>
/panel
then routing is gonna be like /panel/login
<a href="">
attribute ~ thanks to page.js
(no more need for extra component import, for example: <Link>
)page.js
beforeEnterRoute
, afterRouteEnter
- useful for navigation guards() => import("/TestPage.svelte")
(aka. dynamic importing, lazy loading), import("/TestPage.svelte")
static promise importing or component: TestPageComponent
static/preloaded component passingpageType: "trash"
/post/:postID
- postID
is now our route param, Routve will add this param to page component (export let postID;
)page.js
/some-route?example=123
- thanks to page.js
path routing
, ideal for SPA and SSR - thanks to page.js
*
is given as pathroute
method and call it route("/login")
SSR support
Sapper support
npm install routve
Always use yarn to avoid conflicting .lock file issues.
Firstly, install all packages with yarn
:
yarn
Secondly, run which example would you like to run: (yarn dev:<example>
see yarn run
or package.json
#scripts)
yarn dev
Merge requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.