Skip to main content
Version: Canary 🚧

Introduction

This project provides a full typescript support. You can use yourrouter in any typescript project.

If you found an issue please reach out to us at @ch3ber_dev on twitter.

Example of code in typescript project

All yourrouter types can be found in yourrouter/types.

src/index.ts
import Router from "yourrouter";
// Import types
import { RouterConfig, Router } from "yourrouter/types";

// Set the router config
const config: RouterConfig = {
path404: "/notFound",
renderId: "#app",
};

// Create router and get the instance
const router: Router = Router.create(config);

// Template to render
const homePage: Template = () => {
return "<p>home</P>"
};

router.addRoute("/", () => {
console.log("welcome to the main route!");

return homePage
});

router.addRoute("/foo", () => {
console.log("welcome to the foo route!");

return () => "<h1>Foo route</h1>"
});