Create simple single-page applications (SPA) with ease using swc-router
. This lightweight routing solution for React applications leverages the speed of SWC.
npm install swc-router
Import Router
, Route
, and Link
components:
import { Router, Route, Link } from 'swc-router'
Define your routes using <Router>
and <Route>
:
<Router>
<Route path='/' Component={() => <h1>Home</h1>} />
// Other routes...
</Router>
Navigate between pages using <Link>
:
<Link to='/'>Home</Link>
- Parameterized routing
- Default
404
route handling - Lazy loading support
- Fully tested with Vitest
Check out a live demo
This project is licensed under the MIT License.
Special thanks to @midudev for inspiration and guidance.