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-mini

v0.0.5

Published

Lightweight, Vue Router–style SPA router for **Svelte 5**. ✨ Simple, minimal, and zero dependencies.

Readme

📘 svelte-router-mini

Lightweight, Vue Router–style SPA router for Svelte 5. ✨ Simple, minimal, and zero dependencies.


🚀 Features

  • Vue Router–like API (RouterView, RouterLink, createRouter)
  • History API (push/replace)
  • Reactive Svelte store for route tracking
  • Automatic active class on <RouterLink>
  • 404 fallback
  • Tiny footprint

📦 Installation

npm install svelte-router-mini
# or
pnpm add svelte-router-mini

🛠️ Usage

1. Define routes

<script>
  import { createRouter, RouterView, RouterLink } from "svelte-router-mini";
  import Home from "./routes/Home.svelte";
  import About from "./routes/About.svelte";
  import Todos from "./routes/Todos.svelte";
  import FallBack from "./routes/FallBack.svelte"

  // init router
  const router = createRouter([
    { path: "/", component: Home },
    { path: "/about", component: About },
    { path: "/todos", component: Todos },
  ], FallBack);
</script>

<nav>
  <RouterLink to="/">Home</RouterLink>
  <RouterLink to="/about">About</RouterLink>
  <RouterLink to="/todos">Todos</RouterLink>
</nav>

<main>
  <RouterView />
</main>

2. Create pages

src/routes/Home.svelte

<h1>Home Page</h1>

src/routes/About.svelte

<h1>About Page</h1>

src/routes/Todos.svelte

<h1>Todos Page</h1>

3. Navigation programmatically

<script>
  import { createRouter } from "svelte-router-mini";

  const router = createRouter([]);

  function goDashboard() {
    router.push("/dashboard");
  }

  function redirectAfterLogin() {
    router.replace("/dashboard");
  }
</script>

<button onclick={goDashboard}>Go to Dashboard</button>

⚡ API

createRouter(routes: Route[], fallback: Component)

Initialize router with route table.

  • routes: { path: string, component: SvelteComponent }[]

Returns:

  • router.push(path: string) → navigate and add to history
  • router.replace(path: string) → navigate without adding history

<RouterView />

Render the active component based on current route.


<RouterLink to="path">

Navigate to a path. Adds "active" class when route is current.

Props:

  • to: string → path to navigate
  • className?: string → optional custom class

📂 Project Structure Example

src/
 ├─ routes/
 │   ├─ Home.svelte
 │   ├─ About.svelte
 │   └─ Todos.svelte
 ├─ App.svelte
 └─ main.js

🌍 Roadmap

  • [ ] Dynamic routes (/todos/:id)
  • [ ] Nested routes
  • [ ] Navigation guards (beforeEach)
  • [ ] Lazy loading

🐞 Issues

If you find a bug or have feature requests, please open an issue.


📄 License

MIT © alijundev