Navigated to /docs/core/api/errors-and-code-splitting

Errors and code splitting API

Error boundaries and lazy component contracts for pending, failure, and loaded states.

Errors and code splitting exports

12 public exports, grouped under their canonical import boundary.

@tavojs/core

Canonical import boundary for every symbol in this section.

ErrorBoundary#

ErrorBoundary(props: ErrorBoundaryProps): ErrorBoundaryVNode

Creates an error boundary vnode that captures descendant render errors.

Related guide

ErrorBoundaryProps#

type ErrorBoundaryProps = {
    children?: Child;
    fallback: ErrorBoundaryFallback;
    resetKey?: unknown;
};

Defines the props accepted by error boundary in the application runtime.

Related guide

lazy#

lazy<P extends Record<string, unknown> = Record<string, unknown>>(loader: LazyLoader<P>, options?: LazyOptions | undefined): LazyComponent<P>

Creates a component that loads its implementation with a dynamic import on first render.

Related guide

LazyComponent#

type LazyComponent<P extends Record<string, unknown>> = Component<P> & {
    preload(): Promise<Component<P>>;
    getStatus(): LazyStatus<P>;
};

Defines the lazy component contract used by the application runtime.

Related guide

LazyErrorFallback#

type LazyErrorFallback = Child | ((state: LazyErrorState) => Child);

Defines the lazy error fallback contract used by the application runtime.

Related guide

LazyErrorState#

type LazyErrorState = {
    status: "error";
    error: unknown;
};

Represents the observable state of lazy error in the application runtime.

Related guide

LazyFallback#

type LazyFallback = Child | ((state: LazyPendingState) => Child);

Defines the lazy fallback contract used by the application runtime.

Related guide

LazyLoader#

type LazyLoader<P extends Record<string, unknown>> = () => Promise<LazyModule<P>>;

Defines the lazy loader contract used by the application runtime.

Related guide

LazyModule#

type LazyModule<P extends Record<string, unknown>> = Component<P> | {
    default: Component<P>;
};

Defines the lazy module contract used by the application runtime.

Related guide

LazyOptions#

type LazyOptions = {
    fallback?: LazyFallback;
    errorFallback?: LazyErrorFallback;
};

Configures lazy in the application runtime.

Related guide

LazyPendingState#

type LazyPendingState = {
    status: "idle" | "loading";
};

Represents the observable state of lazy pending in the application runtime.

Related guide

LazyStatus#

type LazyStatus<P extends Record<string, unknown>> = {
    status: "idle";
    component: null;
    error: null;
} | {
    status: "loading";
    component: null;
    error: null;
} | {
    status: "loaded";
    component: Component<P>;
    error: null;
} | {
    status: "error";
    component: null;
    error: unknown;
};

Defines the lazy status contract used by the application runtime.

Related guide