1.1.1 • Published 10 months ago

simple-typescript-router v1.1.1

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

simple-typescript-router

A really simple JavaScript/TypeScript router

  • ~1kb minified ~0.5kb compressed

npm

import { Router } from "simple-typescript-router";

const router = new Router();
const title = <HTMLHeadingElement>document.querySelector("#title");

router
  .add("/blog/:id/post/:postid", ({ id, postid }) => {
    title.innerText = `blog ${id} : ${postid}`;
  })
  .add("/", () => {
    title.innerText = "home";
  })
  .add("_404", () => {
    title.innerHTML = "404";
  })
  .check();

web

import { Router } from "https://esm.sh/simple-typescript-router";

const router = new Router();
const title = <HTMLHeadingElement>document.querySelector("#title");

router
  .add("/blog/:username/post/:postid", ({ username, postid }) => {
    title.innerText = `${username} : ${postid}`;
  })
  .add("/", () => {
    title.innerText = "home";
  })
  .add("_404", () => {
    title.innerHTML = "404";
  })
  .check();
1.1.1

10 months ago

1.1.0

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago