npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@svelte-router/core

v1.0.7

Published

Next-level routing for Svelte and Sveltekit

Downloads

1,093

Readme

 Svelte Router

Next-level routing for Svelte and Sveltekit.

REPL Demo

Full Documentation

Features

  • Always-on path and hash routing: Simultaneous, independent and always-on routing modes.
  • Multi hash routing: Doing micro-frontends? Routing tabs or dialogs using the URL? Have as many paths as needed.
  • Sveltekit support: Add hash routing on top of Sveltekit's path routing via @svelte-router/kit
  • Electron support: Works with Electron (all routing modes)
  • Reactivity-based: All data is reactive, reducing the need for events and imperative programming.
  • URL Redirection: Use Redirector instances to route users from deprecated URL's to new URL's, even across routing universes.
  • Dynamic Routes: Define routes in JavaScript from any dynamic source, even fetched data.
  • Fully Typed: Built-in TypeScript, even for route parameters.

Components:

  • <Router>
  • <Route>
  • <Fallback>
  • <Link>
  • <LinkContext>
  • <RouterTrace>

Reactive Data:

  • location.url
  • location.path
  • location.hashPaths
  • location.getState()
  • RouterEngine.routes
  • RouterEngine.routeStatus
  • RouterEngine.basePath

All data is a Svelte signal. Add routes dynamically or reactively, change route conditions on the fly, add more pieces of user interface on-demand, etc. All works reactively.

Two Library Modes

Most people only need the normal or "lite" version. Use the full version to battle/counter foreign routers (micro-frontend scenarios, most likely).

In Full Mode...

  • History API interception: Gain control over the history object to avoid external code/routers from de-synchronizing state.
  • Cancellable beforeNavigate event: Get notified of navigation events, and cancel when appropriate.
  • navigationCancelled event: Get notified whenever navigation is cancelled.

Quickstart

  1. Install the package.
  2. Initialize the library.
  3. Define the routes inside routers.
  4. Modify/Add your navigation links.

Install the package

npm i @svelte-router/core

Initialize the Library

// In your main.ts, or somewhere BEFORE any routers are created:
import { init } from '@svelte-router/core';

/*
Default:

- Lite mode
- Implicit path routing
- No router hierarchy tracing
- Single hash mode
- Log to console.
*/
init(); // Or use initFull() for full-mode.

// Common case:  "I just need good, old-fashioned hash routing."
init({ defaultHash: true });

Electron Variant

In Electron, perform immediate navigation to clean the environment's path:

import { init, location } from '@svelte-router/core';

init();
location.goTo('/');

⚠️ Important: Hash routing doesn't require this extra navigation step.

For applications that also run in the browser, condition the navigation to Electron only. See the Electron page online for more details.

Define the Routes

<script lang="ts">
    import { Router, Route } from '@svelte-router/core';
    import NavBar from './lib/NavBar.svelte';
    import UserView from './lib/UserView.svelte';
</script>

<Router>
    <NavBar />
    <div class="container">
        <!-- content outside routes is always rendered -->
        <h1>Routing Demo</h1>
        <Route key="users" path="/users">
            <!-- content here -->
        </Route>
        <Route key="user" path="/users/:userId">
            <!-- access parameters via the snippet parameter -->
            {#snippet children({ rp })}
                <UserView id={rp?.userId} /> <!-- Intellisense will work here!! -->
            {/snippet}
        </Route>
        ...
    </div>
</Router>

Navigation Links

The best practice is to render the links inside a router's hierarchy, but this is not mandatory.

<!-- NavBar.svelte -->
<script lang="ts">
    import { Link } from '@svelte-router/core';
</script>

<nav>
    <div class="nav-links">
        <ul>
            <li class="nav-link">
                <Link href="/users" activeFor="users" activeState={{ class: 'active' }}
                    >All Users</Link
                >
            </li>
            ...
        </ul>
    </div>
</nav>

Issues Here

Questions, Polls, Show & Tell, etc. Here