React Router API Reference
    Preparing search index...

    Config to be exported via the default export from react-router.config.ts.

    type Config = {
        allowedActionOrigins?: string[];
        appDirectory?: string;
        basename?: string;
        buildDirectory?: string;
        buildEnd?: BuildEndHook;
        future?: [keyof FutureConfig] extends [never]
            ? { [key: string]: never }
            : Partial<FutureConfig>;
        prerender?:
            | PrerenderPaths
            | { paths: PrerenderPaths; unstable_concurrency?: number };
        presets?: Preset[];
        routeDiscovery?:
            | { manifestPath?: string; mode: "lazy" }
            | { mode: "initial" };
        serverBuildFile?: string;
        serverBundles?: ServerBundlesFunction;
        serverModuleFormat?: ServerModuleFormat;
        ssr?: boolean;
    }
    Index

    Properties

    allowedActionOrigins?: string[]

    An array of allowed origin hosts for action submissions to UI routes (does not apply to resource routes). Supports micromatch glob patterns (* to match one segment, ** to match multiple).

    export default {
    allowedActionOrigins: [
    "example.com",
    "*.example.com", // sub.example.com
    "**.example.com", // sub.domain.example.com
    ],
    } satisfies Config;

    If you need to set this value at runtime, you can do in by setting the value on the server build in your custom server. For example, when using express:

    import express from "express";
    import { createRequestHandler } from "@react-router/express";
    import type { ServerBuild } from "react-router";

    export const app = express();

    async function getBuild() {
    let build: ServerBuild = await import(
    "virtual:react-router/server-build"
    );
    return {
    ...build,
    allowedActionOrigins:
    process.env.NODE_ENV === "development"
    ? undefined
    : ["staging.example.com", "www.example.com"],
    };
    }

    app.use(createRequestHandler({ build: getBuild
    appDirectory?: string

    The path to the app directory, relative to the root directory. Defaults to "app".

    basename?: string

    The React Router app basename. Defaults to "/".

    buildDirectory?: string

    The path to the build directory, relative to the project. Defaults to "build".

    buildEnd?: BuildEndHook

    A function that is called after the full React Router build is complete.

    future?: [keyof FutureConfig] extends [never]
        ? { [key: string]: never }
        : Partial<FutureConfig>

    Enabled future flags

    prerender?:
        | PrerenderPaths
        | { paths: PrerenderPaths; unstable_concurrency?: number }

    An array of URLs to prerender to HTML files at build time. Can also be a function returning an array to dynamically generate URLs.

    unstable_concurrency defaults to 1, which means "no concurrency" - fully serial execution. Setting it to a value more than 1 enables concurrent prerendering. Setting it to a value higher than one can increase the speed of the build, but may consume more resources, and send more concurrent requests to the server/CMS.

    presets?: Preset[]

    An array of React Router plugin config presets to ease integration with other platforms and tools.

    routeDiscovery?: { manifestPath?: string; mode: "lazy" } | { mode: "initial" }

    Control the "Lazy Route Discovery" behavior

    • routeDiscovery.mode: By default, this resolves to lazy which will lazily discover routes as the user navigates around your application. You can set this to initial to opt-out of this behavior and load all routes with the initial HTML document load.
    • routeDiscovery.manifestPath: The path to serve the manifest file from. Only applies to mode: "lazy" and defaults to /__manifest.
    serverBuildFile?: string

    The file name of the server build output. This file should end in a .js extension and should be deployed to your server. Defaults to "index.js".

    serverBundles?: ServerBundlesFunction

    A function for assigning routes to different server bundles. This function should return a server bundle ID which will be used as the bundle's directory name within the server build directory.

    serverModuleFormat?: ServerModuleFormat

    The output format of the server build. Defaults to "esm".

    ssr?: boolean

    Enable server-side rendering for your application. Disable to use "SPA Mode", which will request the / path at build-time and save it as an index.html file with your assets so your application can be deployed as a SPA without server-rendering. Default's to true.