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)" | "/" | "/_home" | "/_home/Supporters" | "/_home/companies" | "/(authed)/apps" | "/(authed)/apps/destroy" | "/auth" | "/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" | "/devtools/updates.json" | "/docs" | "/docs/component-directives" | "/docs/element-directives" | "/docs/experimental" | "/docs/experimental/sections.json" | "/docs/kit" | "/docs/kit/modules" | ... 40 more ... | "/tutorial/[...slug]"

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

RouteId
,
type RouteParams<T extends RouteId> = T extends "/blog/[slug]" | "/blog/[slug]/card.png" | "/docs/[topic]" | "/docs/[topic]/assets" | "/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]/filetree" | "/tutorial/[...slug]" ? {
    ...;
}[T] : Record<...>

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

RouteParams
,
type LayoutParams<T extends RouteId> = T extends "/(authed)" | "/" | "/_home" | "/_home/Supporters" | "/_home/companies" | "/(authed)/apps" | "/(authed)/apps/destroy" | "/auth" | "/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" | "/devtools/updates.json" | "/docs" | "/docs/component-directives" | "/docs/element-directives" | "/docs/experimental" | "/docs/experimental/sections.json" | "/docs/kit" | "/docs/kit/modules" | ... 40 more ... | "/tutorial/[...slug]" ? {
    ...;
}[T] : Record<...>

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. Used for page.route.id and event.route.id.

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

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.

type RouteParams<T extends RouteId> = { /* generated */ } | Record<string, never>;

Edit this page on GitHub llms.txt