All Projects → prateekbh → Preact Async Route

prateekbh / Preact Async Route

Licence: mit
Async route component for preact-router

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Preact Async Route

Preact Lazy Route
Lazy load preact route components
Stars: ✭ 12 (-90.91%)
Mutual labels:  code-splitting, preact
Codesandbox Client
An online IDE for rapid web development
Stars: ✭ 11,122 (+8325.76%)
Mutual labels:  preact
Led Matrix Simulator
🔮 A simple HTML5 LED Matrix Simulator for fun
Stars: ✭ 96 (-27.27%)
Mutual labels:  preact
Razzle
✨ Create server-rendered universal JavaScript applications with no configuration
Stars: ✭ 10,547 (+7890.15%)
Mutual labels:  preact
Leo
Highly Extensible, Declarative Static Site Generator
Stars: ✭ 100 (-24.24%)
Mutual labels:  preact
Mobx Preact
MobX bindings for Preact
Stars: ✭ 117 (-11.36%)
Mutual labels:  preact
Jetpack
🚀 Jetpack – Webpack made more convenient.
Stars: ✭ 1,326 (+904.55%)
Mutual labels:  preact
Made With Webassembly
A showcase of awesome production applications, side projects, and use cases made with WebAssembly (Wasm). 👷
Stars: ✭ 132 (+0%)
Mutual labels:  preact
Preact Cycle
♻️ Minimal functional Virtual DOM rendering using Preact 🚲
Stars: ✭ 120 (-9.09%)
Mutual labels:  preact
Bae
react made easy
Stars: ✭ 113 (-14.39%)
Mutual labels:  code-splitting
Koa React Universal
lightweight React-Koa2 universal boilerplate, only what is essential
Stars: ✭ 112 (-15.15%)
Mutual labels:  code-splitting
Tiny Atom
Pragmatic and concise state management.
Stars: ✭ 109 (-17.42%)
Mutual labels:  preact
Awesome Bundle Size
📝 An awesome list of tools and techniques to make your web bundle size smaller and your web apps load faster.
Stars: ✭ 118 (-10.61%)
Mutual labels:  code-splitting
Pimg
📷 Mini Image Lazy Loader for P(R)eact and Vue
Stars: ✭ 97 (-26.52%)
Mutual labels:  preact
Preact And Typescript
Some simple patterns for Typescript usage with Preact
Stars: ✭ 127 (-3.79%)
Mutual labels:  preact
Dataformsjs
🌟 DataFormsJS 🌟 A minimal JavaScript Framework and standalone React and Web Components for rapid development of high quality websites and single page applications.
Stars: ✭ 95 (-28.03%)
Mutual labels:  preact
Haxe Modular
Haxe-JS code splitting, NPM dependencies bundling, hot-reload
Stars: ✭ 111 (-15.91%)
Mutual labels:  code-splitting
Next Todos
200 lines realtime todos app powered by next.js, preact, jet, redux and now
Stars: ✭ 117 (-11.36%)
Mutual labels:  preact
Tsparticles
tsParticles - Easily create highly customizable particles animations and use them as animated backgrounds for your website. Ready to use components available for React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Solid, Riot and Web Components.
Stars: ✭ 2,694 (+1940.91%)
Mutual labels:  preact
Scoped Style
A tiny css in js library 🚀
Stars: ✭ 129 (-2.27%)
Mutual labels:  preact

preact-async-route

build gzip size

Deprecation notice

preact-x supports Lazy component, which can be used as shown here. Prefer using the Lazy component along with Suspense instead of this package.

This package is still useful for preact versions < 10


Async route component for preact-router

npm i -D preact-async-route

preact-async-route provides <AsyncRoute> tag to load your components lazily.

<AsyncRoute> provides similar props to return a lazily loaded component either as a Promise resolving to the component or return the component in a callback.

<AsyncRoute> also has a loading props, to which you can pass a component to be shown while the component is being lazily loaded.

Version 2.0

Version 2.0 brings support for a new prop component in order to make usage of already imported components now preact-async-route will support 2 props

  1. component this will just take the JSX component itself and NOT the function
  2. for function calls getComponent is the prop

check README 👇

Usage Example

  import { h, render } from 'preact';
  import Router, from 'preact-router';
  import AsyncRoute from 'preact-async-route';
  import Home from './Components/Home/Home.jsx';
  import Terms from './Components/Terms/Terms.jsx';
  import Loading from './Components/Loading/Loading.jsx';
  /** @jsx h */

  /**
    arguments passed to getComponent:
      url -- matched url
      cb  -- in case you are not returning a promise
      props -- props that component will recive upon being loaded
  */
  function getProfile(url, cb, props){
  	return import('../component/Profile/Profile.jsx').then(module => module.default);
  }

  const Main = () => (
  	<Router>
  		<Home path="/" />
  		<Terms path="/terms" />
  		<AsyncRoute path="/profile/:userid" component={Home} />
  		<AsyncRoute path="/friends/:userid" getComponent={getProfile}
            loading={()=>{return <Loading/>}} />
  	</Router>
  );

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].