
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@open-react/react-router-extended
Advanced tools
React Router Dom - Configure your routing with confidence.
React Router Dom - Configure your routing with confidence.
npm i @open-react/react-router-extended
pnpm i @open-react/react-router-extended
yarn i @open-react/react-router-extended
// routes.tsx
import { lazy } from 'react';
import { createExtendedRoutes } from '@open-react/react-router-extended';
import { MainLayout } from '../layouts/main-layout';
const HomePage = lazy(() => import('../pages/home'));
const AboutPage = lazy(() => import('../pages/about'));
export type ApplicationCustomRouteProps = {
title?: string;
crumb?: boolean;
// add more props as your need
// may be `requiredPermissions: Permisson[]` to handle your own authorization logic ?!
};
/**
* Declare your appication routes.
*
* Naming it as a truly constant because this object is readonly by default.
*
* You can also use this object on pages to extract a route's param or redirect using the paths.
*/
const AppRoutes = createExtendedRoutes<ApplicationCustomRouteProps>()({
root: {
path: '',
element: <MainLayout />,
children: {
index: {
index: true,
title: 'Home',
element: <HomePage />,
},
about: {
title: 'About',
path: 'about',
element: <AboutPage />,
},
},
},
});
export default AppRoutes;
// router.tsx
import {
RouteObject,
RouterProvider,
createBrowserRouter,
} from 'react-router-dom';
import { Helmet } from 'react-helmet-async';
import { transformExtendedRoutes } from '@open-react/react-router-extended';
import AppRoutes, { ApplicationCustomRouteProps } from './constants/routes';
/**
* Transform the extended routes to react-router-dom compatible routes.
*/
const transformedRoutes = transformExtendedRoutes<ApplicationCustomRouteProps>({
extendedRoutes: AppRoutes,
onTransformRoute({ route, parentRoute }) {
// be careful when destructuring - as it may cause missing props in the returned RouteObject
// only destruct props you want - and remember to re-assign them to the `transformedRoute` if needed
const { crumb, title, element, ...defaultRouteObject } = route;
const transformedRoute = defaultRouteObject as RouteObject;
// wrap a route's element with customized logics/components
transformedRoute.element = (
<>
{/* automatic update a page's title */}
<Helmet key={title} title={title}></Helmet>
{/* do even more with your own custom route props */}
{element}
</>
);
return transformedRoute;
},
});
console.log('transformed:', transformedRoutes);
const AppRouter = () => (
<RouterProvider router={createBrowserRouter(transformedRoutes)} />
);
export default AppRouter;
// main.tsx
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { Helmet, HelmetProvider } from 'react-helmet-async';
import AppRouter from './router';
import './styles.css';
const app = (
<StrictMode>
<HelmetProvider>
<Helmet titleTemplate="%s | react-router-extended"></Helmet>
<AppRouter />
</HelmetProvider>
</StrictMode>
);
createRoot(document.getElementById('root') as HTMLElement).render(app);
// home-page.tsx
import { Link } from 'react-router-dom';
import AppRoutes from '../constants/routes';
export default function HomePage() {
return (
<div>
<h1>Home page.</h1>
{/* use the AppRoutes to navigate */}
<Link to={AppRoutes.root.children.about.path} className="underline">
Go to About
</Link>
</div>
);
}
FAQs
React Router Dom - Configure your routing with confidence.
The npm package @open-react/react-router-extended receives a total of 0 weekly downloads. As such, @open-react/react-router-extended popularity was classified as not popular.
We found that @open-react/react-router-extended demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.