Framework-agnostic flexible SPA router
There are plenty of client-side routing libraries, but all of them aren't really lightweight and do not support middlewares or guards out-of-the-box
- Expandable with middlewares
- Written in TypeScript
- Batteries included (in a separate package, but it's officially supported)
- Really lightweight (<3kb min+gzip)
npm i @paranatural/turntable @paranatural/turntable-stdlib @paranatural/turntable-react
yarn add @paranatural/turntable @paranatural/turntable-stdlib @paranatural/turntable-react
pnpm add @paranatural/turntable @paranatural/turntable-stdlib @paranatural/turntable-react
import React from 'react'
import ReactDom from 'react-dom'
import { Ghostship } from '@ghostship/core'
import { GhostshipComponent } from '@ghostship/react'
import { HomePage, PostPage, NotFoundPage } from './components/pages'
const ghostship = new Ghostship(
// routes tree
[{
path: '/',
component: HomePage,
}, {
path: '/post/:slug',
components: PostPage,
}],
// options
{
trailingSlash: true,
notFound: NotFoundPage
}
)
ReactDom.render(
<GhostshipComponent instance={ghostship} />,
document.getElementById('react')
)
Feel free to open an issue/discussion with request/report, but ensure you read/follow Contributor Covenant Code of Conduct
Project licensed under MIT License. What it means
Project name, logo, visual design and writing style heavily inspired by Control game (made by Remedy Entertainment)