0.0.3 • Published 1 year ago

@christopy/x-router v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

X-Router

X-Router is an agnostic SPA (Single Page Application) router for any framework.
It allows you to easily define and navigate between routes within your application.

Installation

You can install X-Router using npm or yarn:

npm install @christopy/x-router
yarn add @christopy/x-router

Usage

First, import XRouter into your application:

import XRouter from "@christopy/x-router";

Then, define your routes as an array of route objects, each containing a name, path, and a context function.
The context function will be called whenever the corresponding route is navigated to, and can be used to update the content of your application:

const app = document.getElementById('app')!;

XRouter([
  {
    name: 'home',
    path: '/',
    context: () => app.innerHTML = 'home',
  },
  {
    name: 'about',
    path: '/about',
    context: () => app.innerHTML = 'about',
  }
]);

When a user navigates to a defined route, X-Router will execute the context function associated with that route, allowing you to update the content of your application dynamically.

License

X-Router is released under the MIT License.

0.0.3

1 year ago

0.0.1

1 year ago