Router component for Svelte
Using npm:
$ npm install --save svelte-router
Using yarn:
$ yarn add svelte-router
<div>
<Link to="/home">Home</Link>
<div id="app"></div>
</div>
<script>
import SvelteRouter from 'svelte-router'
import Home from './Home.html'
const { createRouter, Link } = SvelteRouter
const router = createRouter({
'/': Home
})
export default {
onrender () {
router.start('#app')
// router.start(document.querySelector('#app'))
},
onteardown() {
router.teardown()
},
components: {
Link
}
}
</script>
- Add unit test
- Support BrowserHistory mode
- Write a documentation