3.3.0 • Published 2 years ago

@waveplay/pilot v3.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

GitHub license Tests npm minizipped size

NextJS routing for Expo & React Native

Features

  • Drop-in replacement for Next Router
  • Compatible with React Native, falls back to Next Router for web
  • Support for getServerSideProps and getStaticProps
  • Automatic caching based on revalidate prop
  • Hooks for loading events with ability to override routes
  • Optional placeholder component during loading
  • Extremelly customizable and fast
  • Can be used to control areas instead of whole screen

Install

Using NPM

npm install @waveplay/pilot

Using Yarn

yarn add @waveplay/pilot

Getting started for NextJS

No setup is necessary! Just switch your useRouter code over to usePilot and it'll just automatically work.

Check out the full documentation if you'd like to use more features such as area navigation, custom router, placeholders, configuration, controlled rendering, and more!

// Before
const router = useRouter();
router.push('/dashboard');

// After
const pilot = usePilot();
pilot.fly('/dashboard');

Getting started for React Native

Import each page from your /pages directory like the example below.

Pass your getServerSideProps or getStaticProps as the getProps (optional) component for each route and they'll be executed once routed.

If your getStaticProps returns a revalidate value, Pilot will attempt to cache the result for faster loading later on using Tiny LRU.

import * as DashboardPage from 'src/pages/dashboard';
import * as HomePage from 'src/pages';
import * as UserPage from 'src/pages/user/[handle]';

const App = () => {
	return (
		<PilotArea>
			<PilotRoute path={'/'} component={HomePage.default}/>
			<PilotRoute path={'/dashboard'} component={DashboardPage.default} getProps={DashboardPage.getServerSideProps}/>
			<PilotRoute path={'/user/:handle'} component={UserPage.default} getProps={UserPage.getStaticProps}/>
		</PilotArea>
  );
};
export default App;

Basic usage

You can use Pilot the same way as Next Router, except it now works on React Native and Expo projects!

// const router = useRouter();
const pilot = usePilot();

// router.push('/dashboard');
pilot.fly('/dashboard');

// router.back();
pilot.back();

// router.reload();
pilot.reload();

// router.asPath;
pilot.getPath();

// router.query;
pilot.getQuery();

Credits

This project was originally developed as an internal router for WavePlay.

Documentation

License

The MIT License.

3.2.0

2 years ago

3.3.0

2 years ago

3.1.2

3 years ago

3.1.1

3 years ago

2.0.0-next.5

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.0.2

3 years ago

2.0.0-alpha.0

3 years ago

2.0.0-canary.11

3 years ago

2.0.0-canary.10

3 years ago

2.0.0-next.2

3 years ago

2.0.0-next.3

3 years ago

2.0.0-next.0

3 years ago

2.0.0-next.1

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

2.0.0-canary.13

3 years ago

2.0.0-canary.12

3 years ago

2.0.0-canary.14

3 years ago

3.0.0

3 years ago

1.1.1

3 years ago

2.0.0-beta.7

3 years ago

2.0.0-canary.8

3 years ago

2.0.0-canary.7

3 years ago

2.0.0-canary.9

3 years ago

2.0.0-canary.6

3 years ago

2.0.0-canary.5

3 years ago

2.0.0-canary.0

3 years ago

2.3.0

3 years ago

2.0.0-beta.2

3 years ago

2.0.0-beta.1

3 years ago

2.1.0

3 years ago

2.0.0-beta.3

3 years ago

3.1.0

3 years ago

0.0.0

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago