Skip to content
This repository has been archived by the owner on May 31, 2022. It is now read-only.
/ rout3r Public archive

Trie based React Router in under 1 KB

Notifications You must be signed in to change notification settings

tiaanduplessis/rout3r

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rout3r

package version package downloads standard-readme compliant package license make a pull request

Trie based React Router in under 1 KB

Table of Contents

About

Install

This project uses node and npm.

$ npm install rout3r
$ # OR
$ yarn add rout3r

Usage

import React from "react";
import ReactDOM from "react-dom";
import { Router, Link } from "rout3r";

const PageOne = () => (
  <h2>
    Page 1 <Link href="/tiaan?hello=person">go to</Link>
  </h2>
);
const PageTwo = props => (
  <h2>
    Page 2 {props.params.ahhhhh} {JSON.stringify(props.searchParams)}
  </h2>
);

const PageThree = props => <h2>Page 3</h2>;

const PageFour = props => <h2>Page 4</h2>;

function App() {
  return (
    <Router defaultPath="/404">
      <PageOne path="/" />
      <PageThree path="/foo" />
      <PageFour path="/foo/bar" />
      <PageTwo path="/:ahhhhh" />
    </Router>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT