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

nicdev-router

v0.0.5

Published

es una biblioteca de enrutamiento ligera para aplicaciones React, inspirada en React Router. Ofrece una manera sencilla y eficiente de manejar rutas en tu aplicación, incluyendo soporte para rutas dinámicas y carga diferida (lazy loading) de componentes.

Downloads

255

Readme

nicdev-router

es una biblioteca de enrutamiento ligera para aplicaciones React, inspirada en React Router. Ofrece una manera sencilla y eficiente de manejar rutas en tu aplicación, incluyendo soporte para rutas dinámicas y carga diferida (lazy loading) de componentes.

  • Instalación

Puedes instalar la biblioteca utilizando npm:

npm i nicdev-router Uso Básico A continuación, se muestra un ejemplo básico de cómo usar MyRouter en tu aplicación React.

  • Configuración del enrutador

Primero, necesitas importar los componentes necesarios de nicdev-router:

import { Router, Route, Link } from 'myrouter';
import { lazy, Suspense } from 'react';

const LazyHomePage = lazy(() => import('./pages/HomePage'));
const LazyAboutPage = lazy(() => import('./pages/AboutPage'));

function App() {
  return (
    <main>
      <Suspense fallback={<div>Loading...</div>}>
        <Router>
          <Route path="/" component={LazyHomePage} />
          <Route path="/about" component={LazyAboutPage} />
          <Route path="/search/:query" component={({ routeParams }) => (
            <h1>Search results for: {routeParams.query}</h1>
          )} />
        </Router>
      </Suspense>
    </main>
  );
}

export default App;
  • Navegación entre rutas

Puedes utilizar el componente Link para crear enlaces de navegación dentro de tu aplicación:

jsx

import { Link } from 'myrouter';

function HomePage() {
  return (
    <>
      <h1>Home Page</h1>
      <Link to="/about">Go to About Page</Link>
      <Link to="/search/react">Search for "react"</Link>
    </>
  );
}

export default HomePage;
  • Manejo de rutas dinámicas

MyRouter también soporta rutas dinámicas. Por ejemplo, puedes definir una ruta para manejar búsquedas en tu aplicación:

jsx

import { Router, Route } from 'myrouter';

function App() {
  return (
    <Router>
      <Route path="/search/:query" component={({ routeParams }) => (
        <h1>Search results for: {routeParams.query}</h1>
      )} />
    </Router>
  );
}

export default App;
  • API

routes: Un array de objetos de ruta que define los caminos y los componentes a renderizar. defaultComponent: Un componente que se renderiza cuando ninguna ruta coincide (por defecto muestra un mensaje de "404 Not Found"). El componente Route define una ruta en tu aplicación. Acepta las siguientes propiedades:

path: La ruta para la cual este componente debe renderizarse. component: El componente que se renderiza cuando la ruta coincide.

to: La ruta a la que el enlace debe navegar. target: (Opcional) Especifica dónde abrir el documento vinculado. Contribuir Si encuentras algún problema o tienes alguna sugerencia, siéntete libre de abrir un issue o enviar un pull request en el repositorio de GitHub.

  • [https://github.com/XnicolasG/custom-Router] Licencia Este proyecto está licenciado bajo la Licencia MIT.