Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jikkai/svelte-router
Router component for Svelte
https://github.com/jikkai/svelte-router
router router-component svelte
Last synced: about 1 month ago
JSON representation
Router component for Svelte
- Host: GitHub
- URL: https://github.com/jikkai/svelte-router
- Owner: jikkai
- License: mit
- Archived: true
- Created: 2017-01-11T11:01:13.000Z (almost 8 years ago)
- Default Branch: dev
- Last Pushed: 2020-08-07T22:45:51.000Z (over 4 years ago)
- Last Synced: 2024-11-07T08:04:42.683Z (about 2 months ago)
- Topics: router, router-component, svelte
- Language: HTML
- Homepage: https://jikkai.github.io/svelte-router
- Size: 759 KB
- Stars: 62
- Watchers: 4
- Forks: 10
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Svelte Router
![version](https://img.shields.io/npm/v/svelte-router.svg)
![license](https://img.shields.io/github/license/mashape/apistatus.svg)> Router component for Svelte
This branch is for Svelte v3.0.0+. For usage with Svelte v1.8.0+, see the [v2 branch](https://github.com/jikkai/svelte-router/tree/v2). For usage with Svelte v1.8.0-, see the [0.1.x branch](https://github.com/jikkai/svelte-router/tree/0.1.x).
## Installation
Using npm:
```bash
npm install --save svelte-router
```Using yarn:
```bash
yarn add svelte-router
```## Examples
```html
Home
Welcome
import SvelteRouter, { Link } from 'svelte-router'
import Home from './Home.svelte'
import Welcome from './Welcome.svelte'function create (node) {
const router = new SvelteRouter({
target: node,
mode: 'hash',
routes: [{
path: '/',
component: Home
}, {
path: '/welcome',
component: Welcome
}]
})return {
destroy () {
router.destroy()
}
}
}.router-link-active {
color: red;
}```
## API
### SvelteRouter
* `push(path: string)`
* `replace(path: string)`
* `go(n: number)`
* `goBack()`
* `goForward()`
* `listen(fn: function)`### Link
* `to`: string
* `replace`: boolean
* `className`: string
* `activeClassName`: string## Contributors
* [@rumpytim](https://github.com/rumpytim)
* [@RobBrazier](https://github.com/RobBrazier)
* [@stalkerg](https://github.com/stalkerg)