🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

svelte-router

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-router

A simple router for Svelte

latest
Source
npmnpm
Version
3.0.0-alpha.2
Version published
Maintainers
1
Created
Source

Svelte Router

version license

Router component for Svelte

This branch is for Svelte v3.0.0+. For usage with Svelte v1.8.0+, see the v2 branch. For usage with Svelte v1.8.0-, see the 0.1.x branch.

Installation

Using npm:

npm install --save svelte-router

Using yarn:

yarn add svelte-router

Examples

<div>
  <Link to="/">Home</Link>
  <Link to="/welcome">Welcome</Link>
  <div use:create></div>
</div>

<script>
  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()
      }
    }
  }
</script>

<style>
  .router-link-active {
    color: red;
  }
</style>

API

SvelteRouter

  • push(path: string)
  • replace(path: string)
  • go(n: number)
  • goBack()
  • goForward()
  • listen(fn: function)
  • to: string
  • replace: boolean
  • className: string
  • activeClassName: string

Contributors

Keywords

svelte

FAQs

Package last updated on 14 Aug 2019

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