1.2.0 • Published 8 months ago

vanilla-js-ts-router v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

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. Can also use search params if you want to use it for something like github pages

installation

npm i basic-ts-router

Usage

import router, { setRoutes, getFile } from "basic-ts-router";
// getFile gets our html file from your public folder

const routes: Routes = {
  "/": {
    title: "Home",
    content: getFile("/home.html"),
    scripts: [() => import("./home").then((module) => module.default())], // you can also use the method directly but I prever dinamic importing
    condition: () => true,
    fallback: "/login",
  },
  // ... more routes
};

setRoutes(routes);

router();
1.2.0

8 months ago

1.1.9

9 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.0.9

1 year ago