APIContext Type — astro Architecture
Architecture documentation for the APIContext type/interface in context.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD e532817f_eac9_393f_1b81_87c894982dbf["APIContext"] 2b15052d_da7e_1068_8fc4_a995d3529aeb["context.ts"] e532817f_eac9_393f_1b81_87c894982dbf -->|defined in| 2b15052d_da7e_1068_8fc4_a995d3529aeb style e532817f_eac9_393f_1b81_87c894982dbf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/types/public/context.ts lines 137–580
export interface APIContext<
Props extends Record<string, any> = Record<string, any>,
Params extends Record<string, string | undefined> = Record<string, string | undefined>,
> {
/**
* The site provided in the astro config, parsed as an instance of `URL`, without base.
* `undefined` if the site is not provided in the config.
*
* ## Example
*
* ```astro
* <link
* rel="alternate"
* type="application/rss+xml"
* title="Your Site's Title"
* href={new URL("rss.xml", Astro.site)}
* />
* ```
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#site)
*/
site: URL | undefined;
/**
* A human-readable string representing the Astro version used to create the project. It follows the format "Astro v5.x.x".
*
* ## Example
*
* ```astro
* <meta name="generator" content={Astro.generator} />
* ```
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#generator)
*/
generator: string;
/**
* The address (usually IP address) of the user.
*
* Throws an error if used within a static site, or within a prerendered page.
*
* ## Example
*
* ```ts
* import type { APIContext } from 'astro';
*
* export function GET({ clientAddress }: APIContext) {
* return new Response(`Your IP address is: ${clientAddress}`);
* }
* ```
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#clientaddress)
*/
clientAddress: string;
/**
* An object containing utilities for reading and manipulating the values of cookies in on-demand routes.
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#cookies)
*/
cookies: AstroCookies;
/**
* An object containing utilities for handling sessions in on-demand rendered routes.
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#session)
*/
session: AstroSession | undefined;
/**
* A standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object containing information about the current request.
*
* ## Example
*
* To get a URL object of the current URL, you can use:
* ```typescript
* const url = new URL(Astro.request.url);
* ```
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#request)
*/
Defined In
Source
Frequently Asked Questions
What is the APIContext type?
APIContext is a type/interface in the astro codebase, defined in packages/astro/src/types/public/context.ts.
Where is APIContext defined?
APIContext is defined in packages/astro/src/types/public/context.ts at line 137.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free