1.0.31 • Published 1 year ago

sly-svelte-router v1.0.31

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

sly-svelte-spa-router

A SPA router for Svelte based on the History API.

How it works

  1. 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.
  2. Route changes:

    • Routes can be changed using goTo, goNext, goPrev functions, or link and route directives.
    • These trigger custom events ('routing-changed' or 'routing-url-changed').
  3. Route processing:

    • When a route change is requested, the router checks for restrictions.
    • If restricted, it redirects to an allowed route.
  4. Route rendering:

    • The Router.svelte component renders the current route component.
    • It also updates the document title and handles slot content.
  5. History management:

    • The router uses the History API to manage browser history.
    • It pushes or replaces state depending on the navigation action.
  6. 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 and route 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

1 year ago

2.0.0

1 year ago

1.0.29

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago