0.0.14 • Published 6 years ago

pagify-it v0.0.14

Weekly downloads
31
License
MIT
Repository
github
Last release
6 years ago

pagify-it

npm version

Install

yarn add page pagify-it

Usage

import Router, { Link, navigate, redirect } from 'pagify-it';

const Home = () => <div>HOME</div>;
const About = () => <div>ABOUT <Link to="/">HOME</Link></div>;
const Post = props => <div>POST # {props.ctx.params.id}</div>;

const routes = {
  '/': Home,
  '/about': About,
  '/post/:id': Post,
  '*': () => <div>404</div>
};

const App = () => <Router {...{ routes }} />;
// props: routes, opts (optional), base (optional), onChange(path, ctx) (optional)

// to display a link <a />, it accepts a base prop (optional) as well
<Link to="/posts" />

// to navigate to a certain path
navigate('/posts');

// to redirect to a certain path
redirect('/login');

// context: each rendered route will have a `ctx` prop with some routing metadata

Docs

See Page.js.

Example

Available here (source).

Note: Routing with hashes is used in the example for hosting on GitHub pages, in a typical app you won't need it.

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago