Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/content/docs/en/reference/modules/astro-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ import type {

<p>

**Type:** `{addCookieHeader?: boolean; clientAddress?: string; locals?: object; prerenderedErrorPageFetch?: (url: ErrorPagePath) => Promise<Response>; routeData?: RouteData;}`
**Type:** `{addCookieHeader?: boolean; clientAddress?: string; locals?: object; prerenderedErrorPageFetch?: (url: ErrorPagePath) => Promise<Response>; waitUntil?: (promise: Promise<unknown>) => void; routeData?: RouteData;}`
</p>

Describes the options for controlling the routes rendering.
Expand Down Expand Up @@ -346,6 +346,33 @@ return app.render(request, {

If not provided, Astro will fallback to its default behavior for fetching error pages.

#### `RenderOptions.waitUntil()`

<p>

**Type:** `(promise: Promise<unknown>) => void`<br />
<Since v="6.2.0" />
</p>

An optional runtime hook for background work after the response is sent.

Adapters can pass this through to let runtime cache providers schedule work such as cache writes or stale-while-revalidate without blocking the response path.

The following example forwards a runtime's `waitUntil()` implementation to [`app.render()`](#apprender) in an [adapter server entrypoint](/en/reference/adapter-reference/#building-a-server-entrypoint):

```js {8}
import { createApp } from 'astro/app/entrypoint';

const app = createApp();

export async function handler(event, context) {
// ...
return app.render(event.request, {
waitUntil: context.waitUntil.bind(context),
});
}
```

#### `RenderOptions.routeData`

<p>
Expand Down
Loading