
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@route-weaver/react
Advanced tools
The official React integration for route-weaver. It provides a set of custom Hooks for seamless integration with your React applications, making it easy to access navigation data and functions with full typesafety.
Tired of string-based routing leading to runtime errors, broken links, and a frustrating developer experience? Traditional React routing libraries often leave you vulnerable to typos in route paths and mismatches in parameters, issues that typically only surface in the browser.
@route-weaver/react solves this by bringing end-to-end typesafety to your routing. By defining your routes as a structured, typed object, you unlock a new level of confidence and productivity. This library doesn't just manage routes; it creates a contract between your route definitions and your components, ensuring that any attempt to navigate to a non-existent route or pass incorrect parameters is caught by TypeScript at build time, not by your users at runtime.
npm install @route-weaver/core @route-weaver/react
Start by defining your routes and creating a navigation instance with the "all-in-one" createNavigation function. Then, create a fully typesafe React API using createRouteWeaverReactApi.
This factory function returns the RouteWeaverProvider and all the necessary hooks, with TypeScript types automatically inferred from your navInstance.
// src/routing.ts
import { createNavigation } from '@route-weaver/core';
import { createRouteWeaverReactApi } from '@route-weaver/react';
const navInstance = createNavigation({
home: { path: '/', label: 'Home' },
about: { path: 'about', label: 'About' },
posts: { path: 'posts/:id', label: 'Posts' },
});
// Create the typesafe React API
export const {
RouteWeaverProvider,
useNavigation,
useActiveRoute,
useBreadcrumbs,
useBuildPath,
} = createRouteWeaverReactApi(navInstance);
Now, wrap your application with the RouteWeaverProvider.
// src/main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';
import { RouteWeaverProvider } from './routing';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<Router>
<RouteWeaverProvider>
<App />
</RouteWeaverProvider>
</Router>
</React.StrictMode>
);
Note: For more advanced use cases, such as generating multiple navigation structures from a single set of routes, see the
@route-weaver/coredocumentation. BothcreateNavigationandcreateRouteWeaverproduce a fully typesafeNavigationInstance.
useNavigation()navigation object, with each key corresponding to a navigation group.Practical Example:
import { useNavigation } from './routing';
import { Link } from 'react-router-dom';
function Header() {
const navigation = useNavigation();
return (
<nav>
{navigation.main.map(item => (
<Link key={item.id} to={item.path}>
{item.label}
</Link>
))}
</nav>
);
}
useActiveRoute()ActiveRoute object ({ route, params }) or undefined.Practical Example:
import { useActiveRoute } from './routing';
function PageTitle() {
const activeRoute = useActiveRoute();
if (!activeRoute) {
return <h1>404 - Page Not Found</h1>;
}
return <h1>{activeRoute.route.label}</h1>;
}
useBreadcrumbs()StructuredNavItem objects representing the path to the active route.Practical Example:
import { useBreadcrumbs } from './routing';
import { Link } from 'react-router-dom';
function Breadcrumbs() {
const crumbs = useBreadcrumbs();
return (
<nav>
{crumbs.map((crumb, index) => (
<span key={crumb.id}>
<Link to={crumb.fullPath}>{crumb.label}</Link>
{index < crumbs.length - 1 && ' > '}
</span>
))}
</nav>
);
}
useBuildPath()buildPath function, which allows you to construct URLs in a completely typesafe way. It eliminates the risk of typos in paths or parameters, as TypeScript will validate everything at compile time.buildPath(routeId, params) function from the core routeWeaver instance.Practical Example:
import { useBuildPath } from './routing';
import { Link } from 'react-router-dom';
function UserProfileLink({ userId }: { userId: string }) {
const buildPath = useBuildPath();
// Typesafe: 'posts' is a valid route and 'id' is a required param.
const profilePath = buildPath('posts', { id: userId });
return <Link to={profilePath}>View Profile</Link>;
}
Without route-weaver, you might build links with string interpolation, a common source of bugs.
// If the route changes from '/users/:id' to '/profile/:id', this link will break silently.
const profilePath = `/users/${userId}`;
This is fragile. There's no guarantee /users/:id is a valid route, and refactoring is a nightmare.
With route-weaver, useBuildPath gives you full typesafety and autocompletion.
import { useBuildPath } from './routing';
const buildPath = useBuildPath();
// ✅ Correct: TS knows 'posts' is a valid route and 'id' is a required param.
const profilePath = buildPath('posts', { id: '123' });
// ❌ Compile-Time Error: 'userId' is not a valid parameter name.
// const invalidPath = buildPath('posts', { userId: '123' });
// ❌ Compile-Time Error: 'foo' is not a defined route.
// const nonExistentPath = buildPath('foo', { id: '123' });
This immediate feedback prevents bugs and makes refactoring safe and predictable.
Explore interactive examples on CodeSandbox to see @route-weaver/react in action.
Contributions are welcome! Please see the main CONTRIBUTING.md file for details.
MIT
FAQs
React hooks for @route-weaver/core
We found that @route-weaver/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.