Asynchronous loading for Preact Router. For 440B.
Inspired by preact-async-route. Bundled with 📦 Microbundle
npm install --save preact-route-async
import Router from 'preact-router';
import Route from 'preact-route-async';
<Router>
<Route path="/" component={Home} />
<Route
path="/user"
user={user}
getComponent={() => import('./pages/user.js')}
/>
</Router>
Props and children wil automatically be passed to the fetched Component.
The library also passes the path
property, coming from preact-router
to the Component.
Code demo can be found here