0.2.9 • Published 3 years ago

react-pages-router v0.2.9

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Generate routes automatically

Usage

Your App.js/App.ts

import { BrowserRouter, Route, Routes } from 'react-router-dom'; 
import { Router } from 'react-pages-router';

function App() { 
  const pages = require.context('./pages', true, /\.(tsx|js)$/);
  return ( 
    <BrowserRouter> 
      <div className='App'> 
        <Router core={{ Route, Routes }} pages={pages} /> 
      </div>
    </BrowserRouter> 
  ); 
}

export default App;

Create a pages folder

Folder structure

pages/

  • index.js // path = "/"
  • contact.js // path = "/contact"
  • cms/
    • index.js // path = "/cms"
    • users.js // path = "/cms/users"
    • @layout // layout to be use by routes inside cms folder
    • users/
      • _id.js // path = "/users/" files with '_' will serves as parameters
0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

1.0.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago