New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bjornlu/svelte-router

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bjornlu/svelte-router

An easy-to-use SPA router for Svelte

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

Svelte Router

package version npm downloads ci e2e

An easy-to-use SPA router for Svelte.

Comparison with other routers

Features

  • Super simple API
  • Support hash and path based navigation
  • Nested routes
  • Redirects and navigation guards (with async support)
  • Lazy loading routes
  • Auto base tag navigation

Not Supported

  • Server-side rendering (SSR) - Use Sapper instead
  • Relative navigations - Use absolute path and dynamic syntax instead

Quick Start

  1. Install @bjornlu/svelte-router:
$ npm install @bjornlu/svelte-router
  1. Define routes:
// main.js

import { initPathRouter } from '@bjornlu/svelte-router'
import App from './App.svelte'
import Home from './Home.svelte'

// Use `initHashRouter` for hash mode
initPathRouter([
  { path: '/', component: Home }
])

const app = new App({
  target: document.body
})

export default app
  1. Render routes and links:
<!-- App.svelte -->

<script>
  import { RouterView, Link } from '@bjornlu/svelte-router'
</script>

<main>
  <nav>
    <Link to="/">Home</Link>
  </nav>
  <RouterView />
</main>
  1. Done!

Documentation

Ready to learn more? The documentation is split into two parts:

  • Guide: Covers common usage to advanced topics
  • API reference: Covers the structure of the API

Examples

Contributing

All contributions are welcomed. Check out CONTRIBUTING.md for more details.

License

MIT

Keywords

FAQs

Package last updated on 21 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc