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

@pedrovs3-test/react-router

v0.0.44

Published

This is a simple, lightweight, and flexible routing library for React applications. It provides a set of components and hooks to handle routing in your application, including support for dynamic routes with path parameters.

Downloads

21

Readme

@pedrovs3/react-router

Esta é uma biblioteca de roteamento simples, leve e flexível para aplicações React. Ela fornece um conjunto de componentes e hooks para lidar com o roteamento em sua aplicação, incluindo suporte para rotas dinâmicas com parâmetros na URL.

Recursos

  • API Simples: Basta envolver sua aplicação com o componente Router e usar o componente Route para definir suas rotas.
  • Rotas Dinâmicas: Defina facilmente rotas com parâmetros de caminho, como "/user/:id". O componente Route extrairá automaticamente esses parâmetros e os passará para o seu componente.
  • Query Params: Acesse os query params de seus componentes com o hook useRouterContext.
  • Página 404: Defina uma página 404 personalizada que será exibida quando nenhuma rota corresponder.
  • Guarded routes: Defina rotas que só podem ser acessadas se o usuário estiver autenticado.
  • Hooks: Possui hooks para acessar o histórico de navegação e o contexto do roteador.
  • Metadata: Defina metadados para suas rotas, como por exemplo, título da página e descrição para melhorar o SEO.
  • Lazy loading: Suporte para carregamento assíncrono de componentes.
  • Suporte ao TypeScript: Todos os componentes e hooks são totalmente tipados.

Instalação

Você pode instalar esta biblioteca com npm:

npm install @pedrovs3/react-router

Uso

Aqui está um exemplo básico de como usar esta biblioteca:

import { Router, Route } from '@pedrovs3/react-router';
import { lazy } from 'react';

// Example with lazy loading
const About = lazy(() => import('./About'));

const App = () => (
  <Router>
    <Route path="/home" component={Home} />
    <Route 
      path="/about" 
      component={About}
      metadata={{ title: "About page" }} 
    />
    <Route path="/user/:id" component={User} />
    <Route path="*" component={NotFound} />
  </Router>
);

Neste exemplo, Home, About, User e NotFound são seus componentes. O componente User receberá uma prop pathParams com o id da URL.

Por que usar esta biblioteca?

Esta biblioteca foi criada para ser uma alternativa simples e leve ao React Router. Ela não possui muitos recursos, mas é fácil de usar e tem um tamanho menor do que o React Router.

Autor

Pedro Vieira

Contribuindo

Se você quiser contribuir com este projeto, sinta-se à vontade para abrir uma issue ou enviar um pull request.

Licença

MIT