Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

zxlib/solid-router

Repository files navigation

Router for solid js

Installation

npm install @zxlib/solid-router

Usage

import { RouterProvider, Link, RouteSwitch, Route } from '@zxlib/solid-router';

export const App = () => {
  return (
    <RouterProvider>
      <div class="nav">
        <Link path="/">Index</Link>
        <Link path="/route1">Route1</Link>
        <Link path="/route2">Route2</Link>
        <Link path="/prefix4nested/">Sub Routes Index</Link>
      </div>
      <div class="content">
        <RouteSwitch>
          <Route path="/">Index content</Route>
          <Route path="/route1">Route1 Content</Route>
          <Route path="/route2">Route2 Content</Route>
          <Route fallback>No route</Route>
          <Route prefix path="/prefix4nested">
            <div>
              <div class="nav">
                <Link path="/">Sub Index</Link>
                <Link path="/route1">Sub Route1</Link>
                <Link path="/route2">Sub Route2</Link>
              </div>
            </div>
            <div class="nested content">
              <RouteSwitch>
                <Route path="/">Sub Index Content</Route>
                <Route path="/route1">Sub Route1 Content</Route>
                <Route path="/route2">Sub Route2 Content</Route>
                <Route fallback>No sub route</Route>
              </RouteSwitch>
            </div>
          </Route>
        </RouteSwitch>
      </div>
    </RouterProvider>
  );
};

There is some more examples at https://github.com/zxlib/solid-router-examples