getProps() — astro Function Reference
Architecture documentation for the getProps() function in params-and-props.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 8e1831c9_f4fe_7d1f_bf25_5930ce9a67ef["getProps()"] 2b2f7826_50bd_a387_80cc_9a3b7ef783f7["params-and-props.ts"] 8e1831c9_f4fe_7d1f_bf25_5930ce9a67ef -->|defined in| 2b2f7826_50bd_a387_80cc_9a3b7ef783f7 4ea96ceb_bc51_597e_fd04_d316c65766ef["getParams()"] 8e1831c9_f4fe_7d1f_bf25_5930ce9a67ef -->|calls| 4ea96ceb_bc51_597e_fd04_d316c65766ef 30865ff5_73c1_c50a_9d4a_d5524145d666["validatePrerenderEndpointCollision()"] 8e1831c9_f4fe_7d1f_bf25_5930ce9a67ef -->|calls| 30865ff5_73c1_c50a_9d4a_d5524145d666 style 8e1831c9_f4fe_7d1f_bf25_5930ce9a67ef fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/render/params-and-props.ts lines 23–80
export async function getProps(opts: GetParamsAndPropsOptions): Promise<Props> {
const {
logger,
mod,
routeData: route,
routeCache,
pathname,
serverLike,
base,
trailingSlash,
} = opts;
// If there's no route, or if there's a pathname (e.g. a static `src/pages/normal.astro` file),
// then we know for sure they don't have params and props, return a fallback value.
if (!route || route.pathname) {
return {};
}
if (
routeIsRedirect(route) ||
routeIsFallback(route) ||
route.component === DEFAULT_404_COMPONENT
) {
return {};
}
// During build, the route cache should already be populated.
// During development, the route cache is filled on-demand and may be empty.
const staticPaths = await callGetStaticPaths({
mod,
route,
routeCache,
ssr: serverLike,
base,
trailingSlash,
});
// The pathname used here comes from the server, which already encoded.
// Since we decided to not mess up with encoding anymore, we need to decode them back so the parameters can match
// the ones expected from the users
const params = getParams(route, pathname);
const matchedStaticPath = findPathItemByKey(staticPaths, params, route, logger, trailingSlash);
if (!matchedStaticPath && (serverLike ? route.prerender : true)) {
throw new AstroError({
...AstroErrorData.NoMatchingStaticPathFound,
message: AstroErrorData.NoMatchingStaticPathFound.message(pathname),
hint: AstroErrorData.NoMatchingStaticPathFound.hint([route.component]),
});
}
if (mod) {
validatePrerenderEndpointCollision(route, mod, params);
}
const props: Props = matchedStaticPath?.props ? { ...matchedStaticPath.props } : {};
return props;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does getProps() do?
getProps() is a function in the astro codebase, defined in packages/astro/src/core/render/params-and-props.ts.
Where is getProps() defined?
getProps() is defined in packages/astro/src/core/render/params-and-props.ts at line 23.
What does getProps() call?
getProps() calls 2 function(s): getParams, validatePrerenderEndpointCollision.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free