0.0.8 • Published 9 months ago

@sonnetjs/router v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

sonnetjs/router

A simple and lightweight router for SonnetJS.

Installation

npm i @sonnetjs/router

Usage

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

export const routes = router()
  .layout(async () => (await import('./partials/Layout')).default())
  .children([
    router()
      .path('/')
      .component(async () => (await import('./pages/Home')).default())
      .get(),
    router()
      .path('/about')
      .component(async () => (await import('./pages/About')).default())
      .get(),
    router()
      .path('/contact')
      .component(async () => (await import('./pages/Contact')).default())
      .get(),
  ])
  .get();

const history = createBrowserHistory();

export const routers = createRouter()
  .routes(routes)
  .history(history)
  .mountedId('#app-1')
  .get();
// src/main.ts
import App from './App';
import { routers } from './routes';

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

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

9 months ago

0.0.5

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago