Home / Type/ AstroGlobal Type — astro Architecture

AstroGlobal Type — astro Architecture

Architecture documentation for the AstroGlobal type/interface in context.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  1a431148_64f6_9fd5_0a13_c8aaf8f02a09["AstroGlobal"]
  2b15052d_da7e_1068_8fc4_a995d3529aeb["context.ts"]
  1a431148_64f6_9fd5_0a13_c8aaf8f02a09 -->|defined in| 2b15052d_da7e_1068_8fc4_a995d3529aeb
  style 1a431148_64f6_9fd5_0a13_c8aaf8f02a09 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/types/public/context.ts lines 14–129

export interface AstroGlobal<
	Props extends Record<string, any> = Record<string, any>,
	Self = AstroComponentFactory,
	Params extends Record<string, string | undefined> = Record<string, string | undefined>,
> extends APIContext<Props, Params> {
	/**
	 * A standard [ResponseInit](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#init) object describing the outgoing response.
	 *
	 * ## Example
	 *
	 * You can change the status code by assigning a value to this property:
	 * ```typescript
	 * Astro.response.status = 404;
	 * ```
	 *
	 * [Astro reference](https://docs.astro.build/en/reference/api-reference/#response)
	 */
	response: ResponseInit & {
		readonly headers: Headers;
	};

	/**
	 * Allows a component to be recursively called.
	 *
	 * This is useful when you need to render an Astro component from within
	 * itself. `Astro.self` accepts the same properties as the component itself.
	 *
	 * ## Example
	 *
	 * ```astro
	 * ---
	 * const { items } = Astro.props;
	 * ---
	 * <ul>
	 *   {items.map((item) => (
	 *     <li>
	 *       {Array.isArray(item) ? (
	 *         <Astro.self items={item} />
	 *       ) : (
	 *         item
	 *       )}
	 *     </li>
	 *   ))}
	 * </ul>
	 * ```
	 *
	 * [Astro reference](https://docs.astro.build/en/reference/astro-syntax/#astroself)
	 */
	self: Self;

	/**
	 * An object containing utility functions for modifying an Astro component’s
	 * slotted children.
	 *
	 * [Astro reference](https://docs.astro.build/en/reference/astro-syntax/#astroslots)
	 */
	slots: Record<string, true | undefined> & {
		/**
		 * Check whether content for this slot name exists
		 *
		 * @param {string} slotName - The name of the slot to check.
		 * @returns {boolean} Whether the slot exists.
		 *
		 * ## Example
		 *
		 * ```astro
		 * ---
		 * ---
		 * <slot />
		 * {Astro.slots.has('more') && (
		 *   // Do something...
		 * }
		 * ```
		 *
		 * [Astro reference](https://docs.astro.build/en/reference/astro-syntax/#astroslotshas)
		 */
		has(slotName: string): boolean;

		/**
		 * Asynchronously renders the contents of a slot to a string of HTML.
		 *

Frequently Asked Questions

What is the AstroGlobal type?
AstroGlobal is a type/interface in the astro codebase, defined in packages/astro/src/types/public/context.ts.
Where is AstroGlobal defined?
AstroGlobal is defined in packages/astro/src/types/public/context.ts at line 14.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free