Catalog npm
Back to packageRELEASE DETAILS

0.0.1

npm

09-react-router

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

jsxreactrouter
Published5 Aug 2023
Direct dependencies17
Transitive dependenciesNot calculated

README

Current package documentation

09 REACT ROUTER

This npm package provides a custom version of the Router, Route, and Link components for React. These components are designed to be lightweight, flexible, and easy to use, allowing you to handle client-side routing in your React applications efficiently.

Installation

You can install the package using npm or yarn:

npm i 09-react-router

# or

yarn i 09-react-router

Usage

To use React Router components, follow these steps:

  1. Import the components:
import { Router, Route, Link } from '09-react-router'
  1. Set up your routing in your applicaction:

export function App() {
    return (
    <Router>
      <Route
        path="/"
        Component={() => {
          return (
            <>
              <h1>Home</h1>
              <nav>
                <ul>
                  <li>
                    <Link to="/">Home</Link>
                  </li>
                  <li>
                    <Link to="/about">About</Link>
                  </li>
                  <li>
                    <Link to="/contact">Contact</Link>
                  </li>
                </ul>
              </nav>
            </>
          );
        }}
      />
      <Route
        path="/about"
        Component={() => {
          return (
            <>
              <h1>About</h1>
              <nav>
                <ul>
                  <li>
                    <Link to="/">Home</Link>
                  </li>
                  <li>
                    <Link to="/about">About</Link>
                  </li>
                  <li>
                    <Link to="/contact">Contact</Link>
                  </li>
                </ul>
              </nav>
            </>
          );
        }}
      />
      <Route
        path="/contact"
        Component={() => {
          return (
            <>
              <h1>Contact</h1>
              <nav>
                <ul>
                  <li>
                    <Link to="/">Home</Link>
                  </li>
                  <li>
                    <Link to="/about">About</Link>
                  </li>
                  <li>
                    <Link to="/contact">Contact</Link>
                  </li>
                </ul>
              </nav>
            </>
          );
        }}
      />
    </Router>
    )
}
  1. Define your route components:
export const Home = () => <h2>Home</h2>
export const About = () => <h2>About</h2>
export const Contact = () => <h2>Contact</h2>

Components

Router

The Router component is the top-level component that holds the routing configuration and renders the appropriate Route component based on the current URL.

Props:

routes: (Optional) Array with optional routes instead of Route component. Example:

const routes = [
    {
     path: '/',
     Component: () => <h1>Home</h1>
    },
    {
     path: '/about',
     Component: () => <h1>About</h1>
    }
]

defaultComponent: (Optional) Default component to render if any routes or children in Router is founded.

Route

The Route component is used to define a route and render the corresponding component when the URL matches the specified path.

Props:

path (string): The URL path for the route. component (function): The React component to render when the URL matches the path.

The Link component is used to create links to navigate between different routes.

Props:

to (string): The URL path to navigate to when the link is clicked.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open a new issue or submit a pull request.

This is just an npm package to recreate a own router for educational purposes only.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 17

Native requirements
17 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
path-to-regexp
Environment
{
  "local_name": "path-to-regexp",
  "alias": false,
  "peer_metadata": null
}
6.2.1runtime
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^18.2.0runtime
react-dom
Environment
{
  "local_name": "react-dom",
  "alias": false,
  "peer_metadata": null
}
^18.2.0runtime
@swc/cli
Environment
{
  "local_name": "@swc/cli",
  "alias": false,
  "peer_metadata": null
}
^0.1.62development
@swc/core
Environment
{
  "local_name": "@swc/core",
  "alias": false,
  "peer_metadata": null
}
^1.3.74development
@testing-library/react
Environment
{
  "local_name": "@testing-library/react",
  "alias": false,
  "peer_metadata": null
}
^14.0.0development
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^18.2.15development
@types/react-dom
Environment
{
  "local_name": "@types/react-dom",
  "alias": false,
  "peer_metadata": null
}
^18.2.7development
@vitejs/plugin-react-swc
Environment
{
  "local_name": "@vitejs/plugin-react-swc",
  "alias": false,
  "peer_metadata": null
}
^3.3.2development
@vitest/ui
Environment
{
  "local_name": "@vitest/ui",
  "alias": false,
  "peer_metadata": null
}
^0.34.1development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.45.0development
eslint-plugin-react
Environment
{
  "local_name": "eslint-plugin-react",
  "alias": false,
  "peer_metadata": null
}
^7.32.2development
eslint-plugin-react-hooks
Environment
{
  "local_name": "eslint-plugin-react-hooks",
  "alias": false,
  "peer_metadata": null
}
^4.6.0development
eslint-plugin-react-refresh
Environment
{
  "local_name": "eslint-plugin-react-refresh",
  "alias": false,
  "peer_metadata": null
}
^0.4.3development
happy-dom
Environment
{
  "local_name": "happy-dom",
  "alias": false,
  "peer_metadata": null
}
^10.7.0development
vite
Environment
{
  "local_name": "vite",
  "alias": false,
  "peer_metadata": null
}
^4.4.5development
vitest
Environment
{
  "local_name": "vitest",
  "alias": false,
  "peer_metadata": null
}
^0.34.1development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-YdmQR32FyDCbFwYq00UaPkJPyMhFQ8UT3yfHtb8oYWQQAsuVanZr5zNKVTov05MMmuru3qgPYfGmJYK+09O5tw==",
  "shasum": "d5073acae47b59c1b986aa0b426a0f942276192a",
  "tarball": "https://registry.npmjs.org/09-react-router/-/09-react-router-0.0.1.tgz",
  "fileCount": 19,
  "unpackedSize": 10246,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCJ7SQSBzIcJu2bZ3L3n6csJVQmZcSbJcLc5/zbTVemygIhAPuZyA2s5+K22GmGSNBfmIBtsSE2UKthPFRvPQp2kuIq"
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:30 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:a0d3f5b145446fe8d677c067cdd42776c36c5965aefd764d9cff55fb3519fa77

Other collected versions

0.0.45 Aug0.0.35 Aug0.0.25 AugView all collected versions →