1.0.31 • Published 4 months ago
sly-svelte-router v1.0.31
sly-svelte-spa-router
A SPA router for Svelte based on the History API.
How it works
Router initialization:
- The
createRouter
function sets up the router with provided routes and configurations. - It adds event listeners for routing changes and popstate events.
- Initializes the first route based on the current URL.
- The
Route changes:
- Routes can be changed using
goTo
,goNext
,goPrev
functions, orlink
androute
directives. - These trigger custom events ('routing-changed' or 'routing-url-changed').
- Routes can be changed using
Route processing:
- When a route change is requested, the router checks for restrictions.
- If restricted, it redirects to an allowed route.
Route rendering:
- The
Router.svelte
component renders the current route component. - It also updates the document title and handles slot content.
- The
History management:
- The router uses the History API to manage browser history.
- It pushes or replaces state depending on the navigation action.
Restrictions:
- Routes can have restrictions that are checked before navigation.
- Custom restriction resolvers can be provided to handle complex logic.
Key Components
Router.svelte
: Main component for rendering routes.createRouter
: Function to initialize the router.link
androute
directives: For declarative routing in templates.goTo
,goNext
,goPrev
: Programmatic navigation functions.
DISCONTINUED
This project is no longer maintained. For an updated and improved version, please check out sly-svelte-location-router.
2.0.1
4 months ago
2.0.0
4 months ago
1.0.29
4 months ago
1.0.31
4 months ago
1.0.30
4 months ago
1.0.28
4 years ago
1.0.27
4 years ago
1.0.26
4 years ago
1.0.25
4 years ago
1.0.24
4 years ago
1.0.23
4 years ago
1.0.22
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago