vite-preload
Version:
Speed up your Vite application by preloading server rendered lazy modules and stylesheets as early as possible
18 lines (17 loc) • 685 B
TypeScript
import { ComponentType } from 'react';
/**
* Drop in replacement for React.lazy that also supports preloading.
*
* Must be used to be able to call `preloadAll()` on the server.
*
* @example const LazyComponent = lazyWithPreload(() => import('./Component'));
*/
export declare function lazy<T extends ComponentType<any>>(factory: () => Promise<{
default: T;
}>): import("react-lazy-with-preload").PreloadableComponent<T>;
/**
* Preload all detected lazy() components.
*
* Can be used on the server to resolve all lazy imports before rendering to avoid the Suspense loading state to be triggered on the first render.
*/
export declare function preloadAll(): Promise<void>;