Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

jikkai/svelte-router

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Svelte Router

version license

Router component for Svelte

Installation

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>

TODO

  • Add unit test
  • Support BrowserHistory mode
  • Write a documentation