React + Loadable Components

This guide has an example repo: examples/react-loadable-components

Based on [app-template-react][app-template-react]

You can lazy load React components in Snowpack when needed with React‘s builtin React.lazy (docs):

import React, {useState, useEffect, Suspense} from 'react';

const Async = React.lazy(() => import('./Async'));

function Component() {
  return (
    <div>
      <Suspense fallback={<div>Loading...</div>}>
        <Async />
      </Suspense>
    </div>
  );
}

This works out-of-the-box in Snowpack, with no configuration needed!

Learn more