vanilla-js-ts-router
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Basic Javascript and TypeScript Router

This is a simple router for a vanilla Javascript and TypeScript frontend. It allows you to define routes with associated content, scripts, conditions, and fallbacks.

installation

npm i basic-ts-router

Usage

First, define your routes:

import router, { setRoutes } from "basic-ts-router";

const routes: Routes = {
  "/": {
    title: "Home",
    content: getFile("/home.html"),
    scripts: [() => import("./home").then((module) => module.default())],
    condition: () => true,
    fallback: "/login",
  },
  // ... more routes
};

setRoutes(routes);

router();

Package Sidebar

Install

npm i vanilla-js-ts-router

Weekly Downloads

2

Version

1.0.9

License

ISC

Unpacked Size

5.25 kB

Total Files

4

Last publish

Collaborators

  • koenmw