RouteData Type — astro Architecture
Architecture documentation for the RouteData type/interface in internal.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 02e5718a_193e_528d_8f1a_e574a10b58b8["RouteData"] 5f8ae14a_9d99_50ef_07ac_b89e2336f3ca["internal.ts"] 02e5718a_193e_528d_8f1a_e574a10b58b8 -->|defined in| 5f8ae14a_9d99_50ef_07ac_b89e2336f3ca style 02e5718a_193e_528d_8f1a_e574a10b58b8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/types/public/internal.ts lines 43–130
export interface RouteData {
/**
* The current **pattern** of the route. For example:
* - `src/pages/index.astro` has a pattern of `/`
* - `src/pages/blog/[...slug].astro` has a pattern of `/blog/[...slug]`
* - `src/pages/site/[blog]/[...slug].astro` has a pattern of `/site/[blog]/[...slug]`
*/
route: string;
/**
* Source component URL
*/
component: string;
/**
* Dynamic and spread route params
* ex. "/pages/[lang]/[...slug].astro" will output the params ['lang', '...slug']
*/
params: string[];
/**
* Output URL pathname where this route will be served
* note: will be undefined for [dynamic] and [...spread] routes
*/
pathname?: string;
/**
* The paths of the physical files emitted by this route. When a route **isn't** prerendered, the value is either `undefined` or an empty array.
*/
distURL: URL[];
/**
*
* regex used for matching an input URL against a requested route
* ex. "[fruit]/about.astro" will generate the pattern: /^\/([^/]+?)\/about\/?$/
* where pattern.test("banana/about") is "true"
*
* ## Example
*
* ```js
* if (route.pattern.test('/blog')) {
* // do something
* }
* ```
*/
pattern: RegExp;
/**
* Similar to the "params" field, but with more associated metadata. For example, for `/site/[blog]/[...slug].astro`, the segments are:
*
* 1. `{ content: 'site', dynamic: false, spread: false }`
* 2. `{ content: 'blog', dynamic: true, spread: false }`
* 3. `{ content: '...slug', dynamic: true, spread: true }`
*/
segments: RoutePart[][];
/**
*
* The type of the route. It can be:
* - `page`: a route that lives in the file system, usually an Astro component
* - `endpoint`: a route that lives in the file system, usually a JS file that exposes endpoints methods
* - `redirect`: a route points to another route that lives in the file system
* - `fallback`: a route that doesn't exist in the file system that needs to be handled with other means, usually the middleware
*/
type: RouteType;
/**
* Whether the route is prerendered or not
*/
prerender: boolean;
/**
* The route to redirect to. It holds information regarding the status code and its destination.
*/
redirect?: RedirectConfig;
/**
* The {@link RouteData} to redirect to. It's present when `RouteData.type` is `redirect`.
*/
redirectRoute?: RouteData;
/**
* A list of {@link RouteData} to fallback to. They are present when `i18n.fallback` has a list of locales.
*/
fallbackRoutes: RouteData[];
/**
* If this route is a directory index
* For example:
* - src/pages/index.astro
* - src/pages/blog/index.astro
*/
Defined In
Source
Frequently Asked Questions
What is the RouteData type?
RouteData is a type/interface in the astro codebase, defined in packages/astro/src/types/public/internal.ts.
Where is RouteData defined?
RouteData is defined in packages/astro/src/types/public/internal.ts at line 43.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free