Home / Function/ renderToResponse() — astro Function Reference

renderToResponse() — astro Function Reference

Architecture documentation for the renderToResponse() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  d7aea22d_3fc3_221d_dab6_a15370f48fd6["renderToResponse()"]
  cb9f7e72_0a2c_f337_8c0f_3a16cbafeab3["experimental_AstroContainer"]
  d7aea22d_3fc3_221d_dab6_a15370f48fd6 -->|defined in| cb9f7e72_0a2c_f337_8c0f_3a16cbafeab3
  765ee439_68bf_1e77_8861_ae817e9e4008["renderToString()"]
  765ee439_68bf_1e77_8861_ae817e9e4008 -->|calls| d7aea22d_3fc3_221d_dab6_a15370f48fd6
  247c0bac_3ec9_44e7_0ee7_5587c9701cc7["create()"]
  d7aea22d_3fc3_221d_dab6_a15370f48fd6 -->|calls| 247c0bac_3ec9_44e7_0ee7_5587c9701cc7
  style d7aea22d_3fc3_221d_dab6_a15370f48fd6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/container/index.ts lines 516–551

	public async renderToResponse(
		component: AstroComponentFactory,
		options: ContainerRenderOptions = {},
	): Promise<Response> {
		const { routeType = 'page', slots } = options;
		const request = options?.request ?? new Request('https://example.com/');
		const url = new URL(request.url);
		const componentInstance =
			routeType === 'endpoint'
				? (component as unknown as ComponentInstance)
				: this.#wrapComponent(component, options.params);
		const routeData = this.#insertRoute({
			path: request.url,
			componentInstance,
			params: options.params,
			type: routeType,
		});
		const renderContext = await RenderContext.create({
			pipeline: this.#pipeline,
			routeData,
			status: 200,
			request,
			pathname: url.pathname,
			locals: options?.locals ?? {},
			partial: options?.partial ?? true,
			clientAddress: '',
		});
		if (options.params) {
			renderContext.params = options.params;
		}
		if (options.props) {
			renderContext.props = options.props;
		}

		return renderContext.render(componentInstance, slots);
	}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does renderToResponse() do?
renderToResponse() is a function in the astro codebase, defined in packages/astro/src/container/index.ts.
Where is renderToResponse() defined?
renderToResponse() is defined in packages/astro/src/container/index.ts at line 516.
What does renderToResponse() call?
renderToResponse() calls 1 function(s): create.
What calls renderToResponse()?
renderToResponse() is called by 1 function(s): renderToString.

Analyze Your Own Codebase

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

Try Supermodel Free