codechips-router

1.0.2 • Public • Published

codechips-router

Lightweight Svelte routing solution. Based on this implementation of page.js by codechips.

Getting started

Pick your favorite package manager:

$ yarn add -D codechips-router
$ npm i -D codechips-router

Edit your App.svelte component

<script>
	import { Router, Route } from "codechips-router";
	import {
		Home,
		About,
	} from "views/index.js";
</script>

<main>
	<Router>
		<Route path="/" component={Home} /> <!-- You can pass the component as a prop -->
		<Route path="/about"> <!-- Or add it directly inline -->
            <h1>About</h1>
            <p>Lorem ipsum dolor sit amet.</p>
        </Route>
	</Router>
</main>

Features

Adding a custom 404 page

<script>
    import { Router, Route, NotFound } from "codechips-router";
    // ...
</script>
<Router>
    <!-- ... -->
    <NotFound>
        <p>Page not found</p>
    </NotFound>
</Router>

Protected routes

To be continued...

Readme

Keywords

Package Sidebar

Install

npm i codechips-router

Weekly Downloads

1

Version

1.0.2

License

GPL-3.0-or-later

Unpacked Size

165 kB

Total Files

12

Last publish

Collaborators

  • oscarmarion