0.0.4 • Published 11 days ago

@sonnetjs/router v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

sonnetjs/router

A simple and lightweight router for SonnetJS.

Installation

npm i @sonnetjs/router

Usage

// src/router.ts
import {
  RouteObject,
  createBrowserHistory,
  createRouter,
} from '@sonnetjs/router';

import Home from './pages/Home';
import About from './pages/About';
import Contact from './pages/Contact';

import RootComponent from './partials/Layout';

const routes: RouteObject[] = [
  {
    rootComponent: RootComponent,
    children: [
      { path: '/', component: Home },
      { path: '/about', component: About },
      { path: '/contact', component: Contact },
    ],
  },
];

const history = createBrowserHistory();

export const router = createRouter({
  routes,
  history,
});
// src/main.ts
import App from './App';
import { router } from './router';

import { createApp } from '@sonnetjs/core';

const app = createApp();
app.root(App);
app.use(router);
app.lazy();
app.mount('#app');
app.initialized();
0.0.4

11 days ago

0.0.3

26 days ago

0.0.2

27 days ago

0.0.1

27 days ago