Skip to main content

$app/types

This module contains generated types for the routes in your app.

Available since 2.26

import type { type RouteId = "/" | "/(authed)/apps" | "/(authed)/apps/destroy" | "/auth/callback" | "/auth/login" | "/auth/logout" | "/blog" | "/blog/rss.xml" | "/blog/the-easiest-way-to-get-started" | "/blog/[slug]" | "/blog/[slug]/card.png" | "/chat" | "/content.json" | "/devtools/updates.json" | "/docs" | "/docs/component-directives" | "/docs/element-directives" | "/docs/experimental/sections.json" | "/docs/kit/modules" | "/docs/llms" | "/docs/logic-blocks" | "/docs/special-elements" | "/docs/[topic]" | "/docs/[topic]/assets/[name]" | "/docs/[topic]/[...path]/card.png" | ... 24 more ... | "/tutorial/[...slug]"

A union of all the route IDs in your app — the union of PageRouteId and EndpointRouteId. Used for page.route.id and event.route.id.

RouteId
, type PageRouteId = "/" | "/(authed)/apps" | "/blog" | "/blog/the-easiest-way-to-get-started" | "/blog/[slug]" | "/docs" | "/docs/component-directives" | "/docs/element-directives" | "/docs/kit/modules" | "/docs/llms" | "/docs/logic-blocks" | "/docs/special-elements" | "/docs/[topic]" | "/docs/[topic]/[...path]" | "/e/[code]" | "/packages" | "/(authed)/playground" | "/(authed)/playground/embed" | "/(authed)/playground/[id]" | "/(authed)/playground/[id]/embed" | "/roadmap" | "/search" | "/tutorial/[...slug]"

A union of the route IDs in your app that have a +page.

A route ID can be in both PageRouteId and EndpointRouteId, if its directory contains both a +page and a +server.

PageRouteId
, type EndpointRouteId = "/(authed)/apps/destroy" | "/auth/callback" | "/auth/login" | "/auth/logout" | "/blog/rss.xml" | "/blog/[slug]/card.png" | "/chat" | "/content.json" | "/devtools/updates.json" | "/docs/experimental/sections.json" | "/docs/[topic]/assets/[name]" | "/docs/[topic]/[...path]/card.png" | "/docs/[topic]/[...path]/llms-small.txt" | "/docs/[topic]/[...path]/llms.txt" | "/edge.svg" | "/e/tmp/codes.json" | "/llms-full.txt" | "/llms-medium.txt" | "/llms-small.txt" | "/llms.txt" | "/(authed)/playground/api/examples/all.json" | "/(authed)/playground/api/[id].json" | ... 4 more ... | "/tutorial/random-number"

A union of the route IDs in your app that have a +server.

A route ID can be in both PageRouteId and EndpointRouteId, if its directory contains both a +page and a +server.

EndpointRouteId
,
type RouteParams<T extends RouteId> = T extends "/blog/[slug]" | "/blog/[slug]/card.png" | "/docs/[topic]" | "/docs/[topic]/assets/[name]" | "/docs/[topic]/[...path]/card.png" | "/docs/[topic]/[...path]/llms-small.txt" | "/docs/[topic]/[...path]/llms.txt" | "/docs/[topic]/[...path]" | "/e/[code]" | "/(authed)/playground/api/[id].json" | "/(authed)/playground/local/[...path]" | "/(authed)/playground/save/[id].json" | "/(authed)/playground/[id]" | "/(authed)/playground/[id]/embed" | "/tutorial/[...slug]" ? {
    "/blog/[slug]": {
        slug: string;
    };
    "/blog/[slug]/card.png": {
        slug: string;
    };
    ... 12 more ...;
    "/tutorial/[...slug]": {
        slug: string;
    };
}[T] : Record<...>

A utility for getting the parameters associated with a given route.

RouteParams
,
type LayoutParams<T extends LayoutParamsId> = {
    "/(authed)": {
        id?: string | undefined;
        path?: string | undefined;
    };
    "/": {
        slug?: string | undefined;
        topic?: string | undefined;
        name?: string | undefined;
        path?: string | undefined;
        code?: string | undefined;
        id?: string | undefined;
    };
    "/docs/[topic]/[...path]": {
        topic: string;
        path: string;
    };
    "/tutorial/[...slug]": {
        slug: string;
    };
}[T]

A utility for getting the parameters associated with a given layout, which is similar to RouteParams but also includes optional parameters for any child route.

LayoutParams
} from '$app/types';

AssetPath

A union of all the filenames of assets contained in your static directory, relative to the base path.

type AssetPath = 'favicon.png' | 'robots.txt' | (string & {});

RouteId

A union of all the route IDs in your app — the union of PageRouteId and EndpointRouteId. Used for page.route.id and event.route.id.

type RouteId = '/' | '/my-route' | '/my-other-route/[param]' | '/my-endpoint';

PageRouteId

A union of the route IDs in your app that have a +page.

A route ID can be in both PageRouteId and EndpointRouteId, if its directory contains both a +page and a +server. In the example below, /my-route has both.

type PageRouteId = '/' | '/my-route' | '/my-other-route/[param]';

EndpointRouteId

A union of the route IDs in your app that have a +server.

A route ID can be in both PageRouteId and EndpointRouteId, if its directory contains both a +page and a +server. In the example below, /my-route has both.

type EndpointRouteId = '/my-route' | '/my-endpoint';

Path

A union of all valid paths in your app, relative to the base path.

type Path = '' | 'my-route' | `my-other-route/${string}` & {};

ResolvedPathname

Similar to Path, but prefixed with a base path. Used for page.url.pathname.

type ResolvedPathname = `${'' | `/${string}`}/` | `${'' | `/${string}`}/my-route` | `${'' | `/${string}`}/my-other-route/${string}` | {};

RouteParams

A utility for getting the parameters associated with a given route.

type type BlogParams = RouteParams<"/blog/[slug]">BlogParams = RouteParams<'/blog/[slug]'>; // { slug: string }
type RouteParams<T extends RouteId> = { /* generated */ } | Record<string, never>;

LayoutParams

A utility for getting the parameters associated with a given layout, which is similar to RouteParams but also includes optional parameters for any child route. It accepts the route ID of any directory containing a layout, including layout-only directories that are not part of RouteId.

type LayoutParams<T extends '/' | '/my-layout' | '/my-other-layout'> = { /* generated */ };

Edit this page on GitHub llms.txt