Svelte Micro screenshot

Svelte Micro

Author Avatar Theme by Ayndqy
Updated: 13 Apr 2025
99 Stars

Light & reactive client-side router for Svelte

Overview

The svelte-micro is a reactive client-side router designed for Svelte. It allows users to easily manipulate the history, push new URLs, replace current URLs, and access and modify router options. This routing system provides a simple and lightweight solution for handling routing in Svelte applications.

Features

  • Router Object: Allows users to manipulate the history by moving through the history, pushing new URLs, and replacing current URLs.
  • Options Store: Provides methods to access and modify router options, including setting the mode and base path for the router.
  • Path Store: A store that contains the current path.
  • Query Store: A store that contains the current query.
  • Hash Store: A store that contains the current hash.
  • Route Component: Defines a route in the application.
  • Link Component: Allows users to create links to other routes in the application.
  • Link Handle Action: Provides methods for handling link actions.
  • getPathSegments Function: Allows users to retrieve the segments of a path.

Installation

To install the svelte-micro routing system, you can use npm:

npm install svelte-micro

Then, you can import the necessary components and functions in your Svelte application:

import { router, type Router } from 'svelte-micro';
import { options, type OptionsStore, type Options } from 'svelte-micro';
import { path, type PathStore, type Path } from 'svelte-micro';
import { query, type QueryStore, type Query } from 'svelte-micro';
import { hash, type HashStore, type Hash } from 'svelte-micro';
import { Route } from 'svelte-micro';
import { Link } from 'svelte-micro';
import { linkHandle, type LinkHandle } from 'svelte-micro';
import { getPathSegments, type GetPathSegments } from 'svelte-micro';

Summary

The svelte-micro routing system is a lightweight and reactive client-side router for Svelte. It provides an easy-to-use API for manipulating the history, defining routes, and creating links in Svelte applications. With its simple installation process and comprehensive set of features, it is a great choice for handling routing in Svelte projects.