npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@crossfox/react-router

v1.0.2

Published

Lightning-fast and highly functional router for React. Effortlessly manage your application's routing with speed and efficiency

Downloads

10

Readme

@crossfox/react-router

npm version Blazing Fast gzip size NPM downloads license

Overview

@crossfox/react-router is a powerful and customizable routing library for React applications. It provides an intuitive way to manage your application's routes and their corresponding components. With @crossfox/react-router, you can create complex navigation systems and handle various routing scenarios with ease.

Features

  • Simple and intuitive API
  • Flexible configuration options
  • Full control over routing and navigation
  • Customizable route matching and handling

Installation

npm install @crossfox/react-router

or

yarn add @crossfox/react-router

Usage

import React from 'react';
import createRouter from '@crossfox/react-router';

const MainPage = () => <h1>Main Page</h1>;
const AboutPage = () => <h1>About Page</h1>;

const UserWithIdPage = ({ id }) => <h1>User {id}</h1>;

const UserWithNamePage = ({ name }) => <h1>User {name}</h1>;
const BlogListWithChildrenPage = () => <h1>Blog list</h1>;

const BlogViewWithChildrenPage = ({ id }) => <h1>Blog post {id}</h1>;
const BlogAddWithChildrenPage = () => <h1>Blog add</h1>;

const BlogEditWithChildrenPage = ({ id, action }) => <h1>Blog post {id}. Action: {action}</h1>;
const Custom404Page = () => <h1>Custom 404</h1>;

const Router = createRouter({
	'': MainPage, // or [MainPage]
	'about': [AboutPage],
	'user/:id': [UserWithIdPage, /[0-9]+/],
	'user/:name': [UserWithNamePage, /[a-zA-Z0-9_]+/],
	'blog': {
		list: BlogListWithChildrenPage,
		add: BlogAddWithChildrenPage,
		':id': {
			'$root': [/[0-9]+/], // for ":id"
			'view': BlogViewWithChildrenPage,
			'edit/:action': [BlogEditWithChildrenPage, /main|user|content/]
		}
	},
	'.+': Custom404Page // For change Page 404
});

const App = () => <Router/>

export default App

Author

API

<Link to="url">Link</Link>

The Link component creates links for navigation between routes.

| Property | Type | Description | |----------|------------------------------------|---------------------------------------------------------------| | to | string | Specifies the target location of the link | | tagName | string (optional) | Defines the HTML tag to be used for the link (default is a) | | data | Record<string, string> (optional) | Additional data associated with the link | | onClick | (e: MouseEvent) => void (optional) | Event handler for the click event on the link | | href | string (optional) | Specifies the hyperlink destination URL for the link |

goTo(url: string, data?:object) :void

The goTo function allows you to navigate to a specific route programmatically.

goBack(level=-1) :void

The goBack function allows you to navigate back to the previous route in the navigation history.

useHistory() :array

The useHistory hook allows access to the navigation history within your components. Return array

useNavigate() :function

The useNavigate hook provides a simple way to navigate between routes programmatically. Return method for change router

useLayout() :string

The useLayout hook allows you to access the current layout information within your components.

useRouterData() :array

The useRouterData hook provides access to the data associated with the current route.