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 = string

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 string ? Record<string, string> : Record<string, never>

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

RouteParams
, type LayoutParams<T extends RouteId> = T extends string ? Record<string, string> : Record<string, never>

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';

Asset

A union of all the filenames of assets contained in your static directory, plus a string wildcard for asset paths generated from import declarations.

type Asset = '/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]';

Pathname

A union of all valid pathnames in your app.

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

ResolvedPathname

Similar to Pathname, but possibly 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