@sanity/routes
    Preparing search index...

    Interface RouteEntry

    Maps one or more document types to a URL path pattern.

    Each entry defines how documents of the specified types resolve to URLs under a given basePath. The pathExpression is a GROQ expression evaluated against each document to produce the path segment.

    // Simple slug-based route
    const blogRoute: RouteEntry = {
    types: ['blogPost'],
    basePath: '/blog',
    // pathExpression defaults to 'slug.current'
    }

    // Parent-child route with custom path expression
    const docsRoute: RouteEntry = {
    types: ['article'],
    basePath: '/docs',
    pathExpression: '*[_type == "section" && references(^._id)][0].slug.current + "/" + slug.current',
    mode: 'parentSlug',
    parentType: 'section',
    }

    // i18n route with locale-specific slugs
    const productRoute: RouteEntry = {
    types: ['product'],
    basePath: '/products',
    pathExpression: 'slug[_key == $locale][0].value',
    locales: ['en', 'fr', 'de'],
    }
    interface RouteEntry {
        _key?: string;
        basePath: string;
        baseUrls?: BaseUrlEntry[];
        locales?: string[];
        mode?: "simpleSlug" | "parentSlug" | "custom";
        parentReferenceField?: string;
        parentRelationship?: "parentReferencesChild" | "childReferencesParent";
        parentSlugField?: string;
        parentType?: string;
        pathExpression?: string;
        slugField?: string;
        types: string[];
    }
    Index

    Properties

    _key?: string
    basePath: string

    URL path prefix. Leading slash added automatically if missing. Example: /blog

    baseUrls?: BaseUrlEntry[]

    Per-route base URL overrides. Takes precedence over channel-level baseUrls.

    locales?: string[]

    Supported locales for this route. When set, separate route map shards are created per locale (e.g., routes-web-product-en).

    mode?: "simpleSlug" | "parentSlug" | "custom"

    Route mode hint for Studio UI. Does not affect resolver behavior.

    parentReferenceField?: string

    Reference field name on the parent document.

    parentRelationship?: "parentReferencesChild" | "childReferencesParent"

    How parent and child documents are related. 'parentReferencesChild': parent has reference array to children. 'childReferencesParent': child has reference to parent.

    parentSlugField?: string

    Slug field on the parent document. Defaults to 'slug'.

    parentType?: string

    Parent document type for parentSlug mode.

    pathExpression?: string

    GROQ expression evaluated per document to produce the URL path segment. Defaults to slug.current. The variable $locale is available when locales are configured.

    slugField?: string

    Field name for the slug. Defaults to 'slug'. Used by Studio components.

    types: string[]

    Document type names that this route handles.