From a0f9bf8a8d267d196d4a35dbc40451379ff2c831 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 12 Feb 2026 15:56:12 +0100 Subject: [PATCH 1/6] feat: add streaming arg to createApp() --- .changeset/warm-donuts-learn.md | 15 +++++++++++++++ packages/astro/dev-only.d.ts | 2 +- packages/astro/src/core/app/entrypoint/dev.ts | 9 ++++----- packages/astro/src/core/app/entrypoint/prod.ts | 8 ++++---- packages/astro/src/core/app/types.ts | 3 +++ 5 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 .changeset/warm-donuts-learn.md diff --git a/.changeset/warm-donuts-learn.md b/.changeset/warm-donuts-learn.md new file mode 100644 index 000000000000..5efd214cb502 --- /dev/null +++ b/.changeset/warm-donuts-learn.md @@ -0,0 +1,15 @@ +--- +'astro': minor +--- + +Adds `streaming` option to the `createApp()` function exported from `astro/app/entrypoint` + +`createApp()` allows adapters to create an `App` instance that works in development and in production. + +It now accepts `streaming` (defaults to `true`) as an argument, forwarded to the `App` constructor: + +```ts +import { createApp } from 'astro/app/entrypoint' + +const app = createApp(false) // Streaming disabled +``` diff --git a/packages/astro/dev-only.d.ts b/packages/astro/dev-only.d.ts index f428b7699af9..96f3a94d7924 100644 --- a/packages/astro/dev-only.d.ts +++ b/packages/astro/dev-only.d.ts @@ -79,5 +79,5 @@ declare module 'virtual:astro:dev-css-all' { } declare module 'virtual:astro:app' { - export function createApp(): import('./src/core/app/base.js').BaseApp; + export const createApp: import('./src/core/app/types.js').CreateApp; } diff --git a/packages/astro/src/core/app/entrypoint/dev.ts b/packages/astro/src/core/app/entrypoint/dev.ts index 824f31e8e67a..7d9643b2999e 100644 --- a/packages/astro/src/core/app/entrypoint/dev.ts +++ b/packages/astro/src/core/app/entrypoint/dev.ts @@ -1,15 +1,14 @@ import { manifest } from 'virtual:astro:manifest'; -import type { BaseApp } from '../base.js'; import { DevApp } from '../dev/app.js'; import { createConsoleLogger } from '../logging.js'; -import type { RouteInfo } from '../types.js'; +import type { CreateApp, RouteInfo } from '../types.js'; import type { RoutesList } from '../../../types/astro.js'; let currentDevApp: DevApp | null = null; -export function createApp(): BaseApp { +export const createApp: CreateApp = (streaming) => { const logger = createConsoleLogger(manifest.logLevel); - currentDevApp = new DevApp(manifest, true, logger); + currentDevApp = new DevApp(manifest, streaming, logger); // Listen for route updates via HMR if (import.meta.hot) { @@ -30,4 +29,4 @@ export function createApp(): BaseApp { } return currentDevApp; -} +}; diff --git a/packages/astro/src/core/app/entrypoint/prod.ts b/packages/astro/src/core/app/entrypoint/prod.ts index 314944c8c32d..84b1de81f676 100644 --- a/packages/astro/src/core/app/entrypoint/prod.ts +++ b/packages/astro/src/core/app/entrypoint/prod.ts @@ -1,7 +1,7 @@ import { manifest } from 'virtual:astro:manifest'; -import type { BaseApp } from '../base.js'; import { App } from '../app.js'; +import type { CreateApp } from '../types.js'; -export function createApp(): BaseApp { - return new App(manifest); -} +export const createApp: CreateApp = (streaming) => { + return new App(manifest, streaming); +}; diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 9c26103b7cad..9f66e3d1bcc0 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -19,6 +19,7 @@ import type { LoggerLevel } from '../logger/core.js'; import type { RoutingStrategies } from './common.js'; import type { BaseSessionConfig, SessionDriverFactory } from '../session/types.js'; import type { DevToolbarPlacement } from '../../types/public/toolbar.js'; +import type { BaseApp } from './base.js'; type ComponentPath = string; @@ -199,3 +200,5 @@ export type NodeAppHeadersJson = { value: string; }[]; }[]; + +export type CreateApp = (streaming?: boolean) => BaseApp; From ce9a187277894fe9cebb886d155be76237a049ec Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Fri, 13 Feb 2026 08:50:05 +0100 Subject: [PATCH 2/6] armand's feedback --- .changeset/warm-donuts-learn.md | 4 ++-- packages/astro/src/core/app/entrypoint/dev.ts | 2 +- packages/astro/src/core/app/entrypoint/prod.ts | 2 +- packages/astro/src/core/app/types.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.changeset/warm-donuts-learn.md b/.changeset/warm-donuts-learn.md index 5efd214cb502..d0765525981f 100644 --- a/.changeset/warm-donuts-learn.md +++ b/.changeset/warm-donuts-learn.md @@ -6,10 +6,10 @@ Adds `streaming` option to the `createApp()` function exported from `astro/app/e `createApp()` allows adapters to create an `App` instance that works in development and in production. -It now accepts `streaming` (defaults to `true`) as an argument, forwarded to the `App` constructor: +It now accepts `streaming` (defaults to `true`) as an option, forwarded to the `App` constructor: ```ts import { createApp } from 'astro/app/entrypoint' -const app = createApp(false) // Streaming disabled +const app = createApp({ streaming: false }) ``` diff --git a/packages/astro/src/core/app/entrypoint/dev.ts b/packages/astro/src/core/app/entrypoint/dev.ts index 7d9643b2999e..53399208cac3 100644 --- a/packages/astro/src/core/app/entrypoint/dev.ts +++ b/packages/astro/src/core/app/entrypoint/dev.ts @@ -6,7 +6,7 @@ import type { RoutesList } from '../../../types/astro.js'; let currentDevApp: DevApp | null = null; -export const createApp: CreateApp = (streaming) => { +export const createApp: CreateApp = ({ streaming } = {}) => { const logger = createConsoleLogger(manifest.logLevel); currentDevApp = new DevApp(manifest, streaming, logger); diff --git a/packages/astro/src/core/app/entrypoint/prod.ts b/packages/astro/src/core/app/entrypoint/prod.ts index 84b1de81f676..6cc744d60eae 100644 --- a/packages/astro/src/core/app/entrypoint/prod.ts +++ b/packages/astro/src/core/app/entrypoint/prod.ts @@ -2,6 +2,6 @@ import { manifest } from 'virtual:astro:manifest'; import { App } from '../app.js'; import type { CreateApp } from '../types.js'; -export const createApp: CreateApp = (streaming) => { +export const createApp: CreateApp = ({ streaming } = {}) => { return new App(manifest, streaming); }; diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 9f66e3d1bcc0..572b0f2220bf 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -201,4 +201,4 @@ export type NodeAppHeadersJson = { }[]; }[]; -export type CreateApp = (streaming?: boolean) => BaseApp; +export type CreateApp = (options?: { streaming?: boolean }) => BaseApp; From e5430fed4a6bdd0dcc79d7f28546d06049f4fecd Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 16 Feb 2026 16:48:03 +0100 Subject: [PATCH 3/6] wip --- packages/astro/src/core/app/entrypoints/virtual/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/app/entrypoints/virtual/index.ts b/packages/astro/src/core/app/entrypoints/virtual/index.ts index 88bbdd19485b..13c88755cc32 100644 --- a/packages/astro/src/core/app/entrypoints/virtual/index.ts +++ b/packages/astro/src/core/app/entrypoints/virtual/index.ts @@ -1,4 +1,4 @@ import { createApp as _createApp } from 'virtual:astro:app'; -import type { BaseApp } from '../../base.js'; +import type { CreateApp } from '../../types.js'; -export const createApp: () => BaseApp = _createApp; +export const createApp: CreateApp = _createApp; From 471d357c4337d6a1e44743e73be997c918be31d2 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 17 Feb 2026 14:04:23 +0100 Subject: [PATCH 4/6] Apply suggestions from code review Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- .changeset/warm-donuts-learn.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.changeset/warm-donuts-learn.md b/.changeset/warm-donuts-learn.md index d0765525981f..ccc97a677273 100644 --- a/.changeset/warm-donuts-learn.md +++ b/.changeset/warm-donuts-learn.md @@ -4,12 +4,17 @@ Adds `streaming` option to the `createApp()` function exported from `astro/app/entrypoint` -`createApp()` allows adapters to create an `App` instance that works in development and in production. -It now accepts `streaming` (defaults to `true`) as an option, forwarded to the `App` constructor: +An adapter's `createApp()` function now accepts `streaming` (defaults to `true`) as an option. HTML streaming breaks a document into chunks to send over the network and render on the page in order. This normally results in visitors seeing your HTML as fast as possible but factors such as network conditions and waiting for data fetches can block page rendering. + +HTML streaming helps with performance and generally provides a better visitor experience. In most cases, disabling streaming is not recommended. + +However, when you need to disable HTML streaming (e.g. your host only supports non-streamed HTML caching at the CDN level), you can opt out of the default behavior by passing `streaming: false` to `createApp()`: ```ts import { createApp } from 'astro/app/entrypoint' const app = createApp({ streaming: false }) ``` + +See more about [the `createApp()` function](https://v6.docs.astro.build/en/reference/adapter-reference/#createapp) in the Adapter API reference. From 350160055641d7fa355d1c9d5bdde2a56ab00649 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 17 Feb 2026 14:13:54 +0100 Subject: [PATCH 5/6] Update .changeset/warm-donuts-learn.md Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- .changeset/warm-donuts-learn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/warm-donuts-learn.md b/.changeset/warm-donuts-learn.md index ccc97a677273..9314af26e1c1 100644 --- a/.changeset/warm-donuts-learn.md +++ b/.changeset/warm-donuts-learn.md @@ -2,7 +2,7 @@ 'astro': minor --- -Adds `streaming` option to the `createApp()` function exported from `astro/app/entrypoint` +Adds `streaming` option to the `createApp()` function in the Adapter API, mirroring the same functionality available when creating a new `App` instance An adapter's `createApp()` function now accepts `streaming` (defaults to `true`) as an option. HTML streaming breaks a document into chunks to send over the network and render on the page in order. This normally results in visitors seeing your HTML as fast as possible but factors such as network conditions and waiting for data fetches can block page rendering. From ba089589fd171f20bbd13dd56b8d02deae0ab366 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 17 Feb 2026 14:43:21 +0100 Subject: [PATCH 6/6] Update .changeset/warm-donuts-learn.md --- .changeset/warm-donuts-learn.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.changeset/warm-donuts-learn.md b/.changeset/warm-donuts-learn.md index 9314af26e1c1..c676a50fc53e 100644 --- a/.changeset/warm-donuts-learn.md +++ b/.changeset/warm-donuts-learn.md @@ -4,7 +4,6 @@ Adds `streaming` option to the `createApp()` function in the Adapter API, mirroring the same functionality available when creating a new `App` instance - An adapter's `createApp()` function now accepts `streaming` (defaults to `true`) as an option. HTML streaming breaks a document into chunks to send over the network and render on the page in order. This normally results in visitors seeing your HTML as fast as possible but factors such as network conditions and waiting for data fetches can block page rendering. HTML streaming helps with performance and generally provides a better visitor experience. In most cases, disabling streaming is not recommended.