Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hookrouter

> 前端框架
Open source

The flexible, and fast router for react that is entirely based on hooks

1.5K stars0 likes4 views
WebsiteGitHub

About

The flexible, and fast router for react that is entirely based on hooks

React Hook Router

The modern alternative to react-router.

Tested from React 16.8.1 upwards.

How to install

Well, this is straightforward:

bash
npm i hookrouter

Typescript

This project is not and will not be written in typescript.

Thanks to the github user @mcaneris, you can install types via:

bash
npm i @types/hookrouter

I did not check if those types are correct nor will I keep them up to date with future releases.

Documentation

Detailed documentation about how to use hookrouter can be found here

A quick example

javascript
import {useRoutes} from 'hookrouter';

const routes = {
    '/': () => <HomePage />,
    '/about': () => <AboutPage />,
    '/products': () => <ProductOverview />,
    '/products/:id': ({id}) => <ProductDetails id={id} />
};
	
const MyApp = () => {
    const routeResult = useRoutes(routes);
    
    return routeResult || <NotFoundPage />;
}

Routes are defined as an object. Keys are the routes, which are matched against the URL, the values need to be functions that are called when a route matches. You may define placeholders in your routes with :something which will be forwarded as props to your function calls so you can distribute them to your components.

The hook will return whatever the route function returned, so you may also return strings, arrays, React fragments, null - whatever you like.

Issues· 64 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScripthooksnavigationqueryparamsreact

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架