diff --git a/apps/docs/markdown.ts b/apps/docs/markdown.ts
index efd5632..c3b605a 100644
--- a/apps/docs/markdown.ts
+++ b/apps/docs/markdown.ts
@@ -121,16 +121,22 @@ export interface SearchEntry {
/**
* A line that is replaced by another file's Markdown: a step several pages
- * share, written once. The path is relative to the page, like a link.
+ * share, written once. The path is relative to the page, like a link. It may be
+ * followed by values for the file's `{{name}}` slots, as `name=value` (no
+ * spaces in the value): ``.
*/
-const INCLUDE = /^$/gm;
+const INCLUDE = /^$/gm;
+
+/** A slot in an included file, filled from the include line. */
+const SLOT = /\{\{([\w-]+)\}\}/g;
/**
- * Puts each included file in the place of its `` line. The
- * text is inlined before it is rendered, so its links resolve from the page
- * that includes it: keep included files one folder down from `contentDir`,
- * like the pages, and the same relative link works from both. An included file
- * cannot include another.
+ * Puts each included file in the place of its `` line, with
+ * its slots filled. The text is inlined before it is rendered, so its links
+ * resolve from the page that includes it: keep included files one folder down
+ * from `contentDir`, like the pages, and the same relative link works from
+ * both. An included file cannot include another. A slot left without a value,
+ * or a value for no slot, fails the build.
*/
export function withIncludes(
source: string,
@@ -138,13 +144,35 @@ export function withIncludes(
options: MarkdownOptions,
): { source: string; included: string[] } {
const included: string[] = [];
- const whole = source.replace(INCLUDE, (_, target: string) => {
+ const whole = source.replace(INCLUDE, (_, target: string, args: string) => {
+ const where = path.relative(options.repoRoot, file);
const absolute = path.resolve(path.dirname(file), target);
if (!existsSync(absolute)) {
- throw new Error(`${path.relative(options.repoRoot, file)}: nothing to include at ${target}`);
+ throw new Error(`${where}: nothing to include at ${target}`);
}
included.push(absolute);
- return readFileSync(absolute, 'utf8').trim();
+ const values = new Map(
+ args
+ .trim()
+ .split(' ')
+ .filter(Boolean)
+ .map((pair) => [pair.slice(0, pair.indexOf('=')), pair.slice(pair.indexOf('=') + 1)]),
+ );
+ const unused = new Set(values.keys());
+ const text = readFileSync(absolute, 'utf8')
+ .trim()
+ .replace(SLOT, (_slot, name: string) => {
+ const value = values.get(name);
+ if (value === undefined) {
+ throw new Error(`${where}: ${target} needs a value for {{${name}}}`);
+ }
+ unused.delete(name);
+ return value;
+ });
+ if (unused.size > 0) {
+ throw new Error(`${where}: ${target} has no slot for ${[...unused].join(', ')}`);
+ }
+ return text;
});
return { source: whole, included };
}
diff --git a/apps/docs/src/content/_shared/allowed-hosts.md b/apps/docs/src/content/_shared/allowed-hosts.md
new file mode 100644
index 0000000..24fb377
--- /dev/null
+++ b/apps/docs/src/content/_shared/allowed-hosts.md
@@ -0,0 +1,3 @@
+`allowedHosts` must list every hostname the server answers for: Angular's SSR
+host guard rejects any other `host` header, and the page is answered with
+`403`.
diff --git a/apps/docs/src/content/_shared/before-you-start.md b/apps/docs/src/content/_shared/before-you-start.md
new file mode 100644
index 0000000..1e7f855
--- /dev/null
+++ b/apps/docs/src/content/_shared/before-you-start.md
@@ -0,0 +1,48 @@
+This setup builds the app with Vite and
+[`@push-based/vite-plugin-ngp`](https://github.com/push-based/vite-plugin-ngp),
+not the Angular CLI. For an app made by `ng new --ssr` that keeps
+`@angular/ssr`, follow [Angular CLI](../getting-started/angular-cli.md)
+instead.
+
+ngp needs Node 26 to build, Vite 8.3 or later, TypeScript 6.0, and every
+`@angular/*` package at exactly `22.3.0-rc.0`, the release it compiles
+against:
+
+```bash
+npm install @angular/core@22.3.0-rc.0 @angular/common@22.3.0-rc.0 @angular/compiler@22.3.0-rc.0 \
+ @angular/platform-browser@22.3.0-rc.0 @angular/platform-server@22.3.0-rc.0 \
+ @angular/router@22.3.0-rc.0 rxjs tslib
+npm install -D @angular/compiler-cli@22.3.0-rc.0 @push-based/vite-plugin-ngp vite typescript@~6.0
+```
+
+The app is an ES module (`"type": "module"` in `package.json`), with
+`vite/client` in its `tsconfig.json`'s `types`. Vite starts from an
+`index.html` that loads `src/main.ts`, which bootstraps the root component as
+usual:
+
+```html title="index.html"
+
+
+
+
+ My app
+
+
+
+
+
+
+
+
+```
+
+```ts title="src/main.ts"
+import { bootstrapApplication } from '@angular/platform-browser';
+import { App } from './app/app';
+import { appConfig } from './app/app.config';
+
+bootstrapApplication(App, appConfig).catch((error) => console.error(error));
+```
+
+The steps below call the root component `App`, in `src/app/app.ts`, and its
+routes `routes`, in `src/app/app.routes.ts`.
diff --git a/apps/docs/src/content/_shared/check-it-streams.md b/apps/docs/src/content/_shared/check-it-streams.md
new file mode 100644
index 0000000..1330e1b
--- /dev/null
+++ b/apps/docs/src/content/_shared/check-it-streams.md
@@ -0,0 +1,17 @@
+Request a page and print when each piece of the response arrives:
+
+```bash
+curl -sN -o /dev/null --trace-time --trace-ascii - {{url}} | grep 'Recv data'
+```
+
+```text
+07:51:38.138747 <= Recv data, 3557 bytes (0xde5)
+07:51:40.145185 <= Recv data, 807 bytes (0x327)
+```
+
+The shell comes at once, as one line or a few with the same time. A line that
+comes later is a chunk, sent when a `@defer` block's data was there: here, one
+block whose request took two seconds. A page with nothing slow on it arrives
+in one piece, so check one that waits for data. If such a page still arrives
+all at once, something held the response back until it was complete; see
+[Checking that a response streams](../guides/streaming-through-proxies.md#checking-that-a-response-streams).
diff --git a/apps/docs/src/content/_shared/event-replay.md b/apps/docs/src/content/_shared/event-replay.md
new file mode 100644
index 0000000..bd176ca
--- /dev/null
+++ b/apps/docs/src/content/_shared/event-replay.md
@@ -0,0 +1,7 @@
+`eventDispatchContract` is for `withEventReplay()`: it is the script Angular
+needs to queue the clicks made before the page hydrates. The handler adds it to
+the template unless the template has it already. The `index.server.html` ngp
+writes for a server build has it; the plain built `index.html`, and the one
+Vite serves in `vite dev`, don't. Leave it out where the template lacks it and
+those clicks are lost; the server logs a warning, once, when the page has
+listeners to replay.
diff --git a/apps/docs/src/content/getting-started/angular-cli.md b/apps/docs/src/content/getting-started/angular-cli.md
index 99f310e..a541115 100644
--- a/apps/docs/src/content/getting-started/angular-cli.md
+++ b/apps/docs/src/content/getting-started/angular-cli.md
@@ -6,6 +6,8 @@ rendered: as a stream, instead of all at once.
Starting from a fresh `ng new my-app --ssr`, that takes changes to four files,
and a fifth, `angular.json`, for the hosts it answers on in production.
+On Angular 19.2, 20.3 or 21.2, two more apply; see
+[Angular 19 to 21](#angular-19-to-21).
## 1. Install
@@ -126,21 +128,23 @@ ng build
node dist/my-app/server/server.mjs # http://localhost:4000, or $PORT
```
-Check that it streams before you put anything in front of it:
+## 8. Check that it streams
-```bash
-curl -sN -o /dev/null --trace-time --trace-ascii - http://localhost:4000/ | grep 'Recv data'
-```
+Before you put anything in front of the server:
-```text
-07:51:38.138747 <= Recv data, 3557 bytes (0xde5)
-07:51:40.145185 <= Recv data, 807 bytes (0x327)
-```
+
-That's the example: the shell at once, and the widget's chunk two seconds
-later, when its data is there. One line for the whole page means something
-buffered it; see
-[Checking that a response streams](../guides/streaming-through-proxies.md#checking-that-a-response-streams).
+## 9. Behind a proxy
+
+A proxy, a CDN or compression middleware can hold the response back until it
+is complete, and the page then arrives all at once. Streamed responses carry
+`X-Accel-Buffering: no` for Nginx; for the rest, read
+[Streaming through proxies](../guides/streaming-through-proxies.md).
+
+## 10. Stream something
+
+Nothing streams until a template has a `@defer` block with a `hydrate`
+trigger: read [Making something stream](../guides/making-something-stream.md).
## What `@angular/ssr` still does
@@ -181,15 +185,3 @@ The steps above are for Angular 22, which `ng new` gives you today. On 19.2,
it may still have a `bootstrap` that takes no argument: add it.
- **On 19**, zoneless is `provideExperimentalZonelessChangeDetection()`. Zone.js
works as well.
-
-## 8. Behind a proxy
-
-A proxy, a CDN or compression middleware can hold the response back until it
-is complete, and the page then arrives all at once. Streamed responses carry
-`X-Accel-Buffering: no` for Nginx; for the rest, read
-[Streaming through proxies](../guides/streaming-through-proxies.md).
-
-## 9. Stream something
-
-Nothing streams until a template has a `@defer` block with a `hydrate`
-trigger: read [Making something stream](../guides/making-something-stream.md).
diff --git a/apps/docs/src/content/getting-started/aws-lambda.md b/apps/docs/src/content/getting-started/aws-lambda.md
index 5b7adf9..1f5a92c 100644
--- a/apps/docs/src/content/getting-started/aws-lambda.md
+++ b/apps/docs/src/content/getting-started/aws-lambda.md
@@ -15,19 +15,34 @@ and nothing in it is an npm dependency of the app, which CDK or SST would add.
> [!IMPORTANT]
> This setup has not been deployed. Everything on this page was built and run
> locally, through a stand-in for the Lambda runtime and the Function URL (see
-> [Check that it streams](#7-check-that-it-streams)). Nothing was checked
+> [Check that it streams](#9-check-that-it-streams)). Nothing was checked
> against a real AWS account. That includes CloudFront, which AWS doesn't
> document as streaming either way.
-## 1. The browser config
+## Before you start
+
+
+
+## 1. Install
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next @push-based/angular-ssr-stream-aws-lambda@next
+npm install -D @types/node
+```
+
+The adapter needs neither the AWS SDK nor `@types/aws-lambda`. Deploying takes
+the [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)
+and the AWS CLI, installed on their own.
+
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The handler
+## 4. The handler
```ts title="src/lambda.ts"
import { join } from 'node:path';
@@ -62,10 +77,9 @@ host the request is rendered for. Function URLs look like
the function's region, so the pattern above matches any Function URL in the
region the function is deployed to, whichever that is.
-`eventDispatchContract` is for `withEventReplay()`, as on
-[Cloudflare Workers](cloudflare-workers.md#3-the-worker).
+
-## 4. Vite
+## 5. Vite
```ts title="vite.config.ts"
import { ngp } from '@push-based/vite-plugin-ngp';
@@ -105,7 +119,7 @@ ngp's own `ssr` option stays off. It builds a `render(url, document)` entry,
not a Lambda handler. ngp still compiles `src/lambda.ts` with its server
compiler, since it's listed in `entries`.
-## 5. The function, CloudFront and S3
+## 6. The function, CloudFront and S3
The whole template is
[`apps/example-aws-lambda/template.yaml`](../../../../../apps/example-aws-lambda/template.yaml).
@@ -158,7 +172,14 @@ these patterns: Vite's hashed files under `assets/*`, plus `*.ico`, `*.svg` and
other files. Everything that doesn't match goes to the function, which renders
it as a page.
-## 6. Build and deploy
+## 7. Develop
+
+`vite dev` serves the app client-side, without the function: Angular renders it
+in the browser and logs NG0505, as there is no hydration data. To see it stream
+before a deploy, run the built function through the stand-in in
+[Check that it streams](#9-check-that-it-streams).
+
+## 8. Build and deploy
```bash
vite build # client to dist/client, handler to dist/server
@@ -174,11 +195,7 @@ template, which only the function reads.
> These commands were not run. The template passes `cfn-lint` with the SAM
> translator, but it has never been deployed.
-## 7. Check that it streams
-
-`curl -N` the page and note when each part arrives. The shell comes at once.
-Each `` chunk follows when its data does. A response that
-arrives all at once after the slowest request was buffered somewhere.
+## 9. Check that it streams
Neither SAM local nor the Runtime Interface Emulator streams a response. The
example has its own stand-in instead,
@@ -189,24 +206,22 @@ Runtime API, and `HttpResponseStream.from()` makes the first write send the
JSON metadata prelude and eight null bytes. A Function URL in front reads the
prelude for the status and headers, and forwards the rest as it arrives.
+Copy the example's
+[`scripts/`](../../../../../apps/example-aws-lambda/scripts/serve.ts) folder,
+both files, into the app. They need nothing but Node:
+
```bash
-pnpm nx serve example-aws-lambda # builds it first; http://localhost:3000/
-curl -sN http://localhost:3000/
+vite build
+node scripts/serve.ts # the built function behind a local Function URL, http://localhost:3000/
```
-Through the stand-in, the example's shell, with the widget's
-`data-placeholder`, arrives at about 0 ms. The widget's
-`` arrives about 2000 ms later.
+
-After a deploy, check the Function URL first and then the CloudFront URL. If
-the Function URL streams and CloudFront doesn't, the buffering is in CloudFront.
-
-```bash
-curl -sN https:///
-curl -sN https:///
-```
+After a deploy, run it against the Function URL first and then the CloudFront
+URL (`SiteUrl`). If the Function URL streams and CloudFront doesn't, the
+buffering is in CloudFront.
-## 8. Stream something
+## 10. Stream something
diff --git a/apps/docs/src/content/getting-started/azure-functions.md b/apps/docs/src/content/getting-started/azure-functions.md
index 3b103aa..da87767 100644
--- a/apps/docs/src/content/getting-started/azure-functions.md
+++ b/apps/docs/src/content/getting-started/azure-functions.md
@@ -13,19 +13,30 @@ There is no adapter package for Azure: the function converts the request and
the response itself, in a few lines, and hands the rest to
[`createStreamingHandler()`](../reference/core.md#createstreaminghandler).
-## 1. The browser config
+## Before you start
+
+
+
+## 1. Install
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next @azure/functions
+npm install -D @types/node
+```
+
+Running it locally takes
+[Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local),
+installed on their own.
+
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The function
-
-```bash
-npm install @azure/functions
-```
+## 4. The function
```ts title="src/functions/ssr.ts"
import { readFile } from 'node:fs/promises';
@@ -90,7 +101,7 @@ the connection chunk by chunk.
The `{*path}` route sends every path, `/` included, to the function. Static
assets never reach it: they are served by the host in front
-([step 7](#7-static-assets)). The core renders a page for whatever reaches it.
+([step 7](#10-static-assets)). The core renders a page for whatever reaches it.
The function answers `GET` and `HEAD`. A method the function doesn't take falls
through to the Functions host, and at `/` the host answers with its own landing
@@ -125,12 +136,9 @@ function app only accepts the request if that hostname is also bound to it as a
custom domain, so add the domain to the function app as well as to Front Door,
and list it in `allowedHosts`.
-`eventDispatchContract` is for `withEventReplay()`. The function renders into
-the built `index.html`, which doesn't carry the script Angular needs to queue
-the clicks made before the page hydrates, so the handler adds it. Leave it out
-and those clicks are lost.
+
-## 4. The function app
+## 5. The function app
A function app on the v4 programming model is a folder with a `host.json` and a
`package.json` whose `main` names the files that register functions:
@@ -173,7 +181,7 @@ ends up once you add one. Commit a `local.settings.example.json` and copy it:
}
```
-## 5. Vite
+## 6. Vite
```ts title="vite.config.ts"
import { ngp } from '@push-based/vite-plugin-ngp';
@@ -209,10 +217,15 @@ own dependencies included, so the deployed app needs no `node_modules`. The one
module left out is `@azure/functions-core`: it isn't a package you install,
the Functions worker provides it when `@azure/functions` asks for it.
-## 6. Run it locally
+## 7. Develop
+
+`vite dev` serves the app client-side, without the function: Angular renders it
+in the browser and logs NG0505, as there is no hydration data. To see it
+stream, build it and run it under Core Tools.
+
+## 8. Build and run locally
-[Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local)
-run the Functions host on your machine, with no Azure account:
+Core Tools run the Functions host on your machine, with no Azure account:
```bash
cp local.settings.example.json local.settings.json
@@ -222,22 +235,20 @@ func start # http://localhost:7071
`func start` serves the function but not the assets, so the page renders and
streams, but doesn't hydrate: every path, `/assets/*.js` included, is rendered
-as a page. Check the stream with `curl`:
+as a page. To see the page hydrate locally, put something in front of
+`func start` that serves `dist/client` and passes every other path on to port
+7071 without buffering, the way Front Door does in production.
-```bash
-curl -sN http://localhost:7071/
-```
+## 9. Check that it streams
+
+With `func start` running:
-The shell, with each `@defer` block's placeholder, arrives at once, and each
-block's `` chunk follows as its data comes in. A response
-that arrives in one piece means something buffered: check `enableHttpStream`
-first.
+
-To see the page hydrate locally, put something in front of `func start` that
-serves `dist/client` and passes every other path on to port 7071 without
-buffering, the way Front Door does in production.
+On Azure Functions, a page that arrives in one piece most often means
+`enableHttpStream` isn't set.
-## 7. Static assets
+## 10. Static assets
The function renders pages only. Everything else in `dist/client`, the
`assets/` folder and the icons, goes to a static host, with navigations routed
@@ -251,7 +262,7 @@ to the function:
routes with caching on, and never a chunked response, so it doesn't hold the
page back to compress it. A chunked response over 8 MB isn't supported.
Point the function app's health probe at `/`: with `HEAD`, the default, it
- gets the status of a real render ([step 3](#3-the-function)).
+ gets the status of a real render ([step 3](#4-the-function)).
- **Azure Static Web Apps, for the assets only.** A linked function app is
reachable only under `/api`, its routes can only be redirected or secured,
not rewritten to, and it has to keep the `/api` prefix this setup removes. So
@@ -260,7 +271,7 @@ to the function:
Keep `index.html` out of the static host: it is the template, not a page.
-## 8. Deploy
+## 11. Deploy
Deploy what you built, not the sources: `host.json`, `package.json`,
`dist/server` and `dist/client/index.html`. The bundle carries its
@@ -320,6 +331,6 @@ Node 22 and gets no newer versions. Node 26 is in preview, on Linux only
> `node_modules`. It hasn't yet been checked against a deployed function app or
> through Front Door.
-## 9. Stream something
+## 12. Stream something
diff --git a/apps/docs/src/content/getting-started/bun.md b/apps/docs/src/content/getting-started/bun.md
index c40daba..a0386e3 100644
--- a/apps/docs/src/content/getting-started/bun.md
+++ b/apps/docs/src/content/getting-started/bun.md
@@ -8,14 +8,18 @@ This is the setup of
[`apps/example-bun`](../../../../../apps/example-bun/src/server.ts), checked
with Bun 1.4.5.
+## Before you start
+
+
+
## 1. Install
```bash
bun add @push-based/angular-ssr-stream-core@next
+bun add -d @types/bun
```
-The core is all a Bun server needs. Vite and ngp still need Node 26 for the
-build; see [Installation](installation.md).
+The core is all a Bun server needs. The build still runs on Node.
## 2. The browser config
@@ -83,15 +87,11 @@ disk, so there's nothing to guard against `..` in it.
A missing file under `/assets/`, such as an old hashed chunk after a deploy,
gets a `404` rather than a page.
-`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the server answers `403`.
+
-`eventDispatchContract` is for `withEventReplay()`. The built `index.html`
-doesn't carry the script Angular needs to queue the clicks made before the
-page hydrates, so the handler adds it. Leave it out and those clicks are lost.
+
-For the types of `Bun`, add `@types/bun` to the app's devDependencies and
-`"bun"` to `types` in `tsconfig.app.json`.
+For the types of `Bun`, add `"bun"` to `types` in `tsconfig.app.json`.
## 5. Vite
@@ -123,33 +123,38 @@ as a string, which is the buffered render this server avoids.
`resolve.noExternal: true` bundles every dependency into the server build, so
`dist/` runs on its own, without `node_modules`.
-## 6. Build and run
+## 6. Develop
+
+`vite dev` doesn't run `src/server.ts`: it serves `index.html` as it is, and
+Angular renders the app in the browser, with HMR but without the stream, and
+with a console warning (NG0505) that there was nothing to hydrate. To see the
+stream, build and run it with Bun, below.
+
+`vite build --watch` with `bun --watch dist/server/server.js` doesn't work
+either: each rebuild empties `dist/server`, and Bun restarts while the file is
+missing and stops with `Module not found`.
+
+## 7. Build and run
```bash
-vite build # client to dist/client, server to dist/server
-bun dist/server/server.js # http://localhost:3000
+vite build # client to dist/client, server to dist/server
+NODE_ENV=production bun dist/server/server.js # http://localhost:3000, or $PORT
```
The build runs on Node; Bun is only needed to run the result. For production,
-ship `dist/` and run the same command, with `PORT` set if 3000 isn't the port.
+ship `dist/` and run the same command. Without `NODE_ENV=production`,
+`Bun.serve()` starts in its development mode.
-To check that it streams, request a page with `curl -N` and note when each part
-arrives. For the example, the shell (with the widget's placeholder) comes at
-once and the widget's `` chunk 2 seconds later. Bun writes
-each chunk of the `ReadableStream` body as it is enqueued, with nothing to
-configure. A response that arrives all at once means something in front of Bun
-buffered it.
+## 8. Check that it streams
-## 7. Development
+
-`vite dev` doesn't run `src/server.ts`: it serves `index.html` as it is, and
-Angular renders the app in the browser, with HMR but without the stream, and
-with a console warning (NG0505) that there was nothing to hydrate. To see the
-stream, build and run it with Bun as above.
+Bun writes each chunk of the `ReadableStream` body as it is enqueued, with
+nothing to configure.
-`vite build --watch` with `bun --watch dist/server/server.js` doesn't work
-either: each rebuild empties `dist/server`, and Bun restarts while the file is
-missing and stops with `Module not found`.
+## 9. Stream something
+
+
## Elysia
@@ -179,8 +184,6 @@ explicitly if the build has more files than that. `assets` is relative to the wo
server from the app's folder.
Unlike the `Bun.serve()` version above, this serves `/index.html` itself as a
-plain file. Checked with Elysia 1.4.32 and `@elysiajs/static` 1.4.12.
-
-## Stream something
-
-
+plain file, the bare template, and renders a page for a missing file under
+`/assets/` instead of answering `404`. Checked with Elysia 1.4.32 and
+`@elysiajs/static` 1.4.12.
diff --git a/apps/docs/src/content/getting-started/cloudflare-workers.md b/apps/docs/src/content/getting-started/cloudflare-workers.md
index ef7150f..443c3eb 100644
--- a/apps/docs/src/content/getting-started/cloudflare-workers.md
+++ b/apps/docs/src/content/getting-started/cloudflare-workers.md
@@ -3,15 +3,26 @@ through Vite, the server bundle running directly in workerd, static assets
served by Cloudflare's `ASSETS` binding, and every navigation falling through
to the rendering Worker.
-## 1. The browser config
+## Before you start
+
+
+
+## 1. Install
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next @push-based/angular-ssr-stream-cloudflare@next
+npm install -D @cloudflare/vite-plugin wrangler
+```
+
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The Worker
+## 4. The Worker
```ts title="src/worker.ts"
import eventDispatchContract from '@angular/core/event-dispatch-contract.min.js?raw';
@@ -27,15 +38,13 @@ export default createStreamingWorker({
}) satisfies ExportedHandler;
```
-`allowedHosts` must list every hostname the Worker answers for: Angular's SSR
-host guard rejects any other `host` header, and the Worker answers `403`.
+
-`eventDispatchContract` is for `withEventReplay()`. The Worker renders into the
-built `index.html`, which doesn't carry the script Angular needs to queue the
-clicks made before the page hydrates, so the Worker adds it. Leave it out and
-those clicks are lost; the Worker logs a warning when that happens.
+
-## 4. Wrangler
+The Worker fetches that `index.html` through the `ASSETS` binding.
+
+## 5. Wrangler
```jsonc title="wrangler.jsonc"
{
@@ -54,7 +63,7 @@ those clicks are lost; the Worker logs a warning when that happens.
through to the Worker, which fetches `/index.html` through `ASSETS` and renders
the route into it. `index.html` is the template, not the page.
-## 5. Vite
+## 6. Vite
```ts title="vite.config.ts"
import { cloudflare } from '@cloudflare/vite-plugin';
@@ -72,14 +81,23 @@ export default defineConfig({
The Cloudflare plugin owns the `ssr` environment and runs it in workerd, so
ngp's own `ssr` option stays off. ngp still compiles the Worker with its server
-compiler. In `vite dev` the `ASSETS` binding is backed by the dev server, so the
-template already carries Vite's transforms and SSR behaves as it does in
-production.
+compiler.
+
+## 7. Develop
-## 6. Build and deploy
+```bash
+vite dev # http://localhost:5173
+```
+
+The Worker runs in workerd, and the `ASSETS` binding is backed by the dev
+server, so the template already carries Vite's transforms and pages stream as
+they do in production.
+
+## 8. Build and deploy
```bash
vite build # client to dist/client, Worker to dist/ssr
+vite preview # the built Worker in workerd, http://localhost:4173
wrangler deploy # deploys the built Worker
```
@@ -87,6 +105,14 @@ wrangler deploy # deploys the built Worker
`.wrangler/deploy/config.json`, so `wrangler deploy` ships the built Worker
rather than `wrangler.jsonc`, whose `main` is TypeScript source.
-## 7. Stream something
+## 9. Check that it streams
+
+With `vite preview` running:
+
+
+
+After the deploy, run the same command against the Worker's address.
+
+## 10. Stream something
diff --git a/apps/docs/src/content/getting-started/deno.md b/apps/docs/src/content/getting-started/deno.md
index 7f84163..7b8a27a 100644
--- a/apps/docs/src/content/getting-started/deno.md
+++ b/apps/docs/src/content/getting-started/deno.md
@@ -8,24 +8,29 @@ The repository's `apps/example-deno` is this setup, and every block below is
taken from it; its server is
[`src/server.ts`](../../../../../apps/example-deno/src/server.ts).
-## 1. The browser config
+## Before you start
-
+
-## 2. The server config
+## 1. Install
-
+```bash
+npm install @push-based/angular-ssr-stream-core@next
+npx jsr add @std/http
+```
-## 3. The server
+`@std/http` comes from JSR. pnpm (10.9 and later) and Yarn take a `jsr:`
+version directly instead: `pnpm add @std/http@jsr:^1.1.4`.
-Install `@std/http` from JSR. pnpm (10.9 and later) and Yarn take a `jsr:`
-version directly; with npm, use `npx jsr add @std/http`.
+## 2. The browser config
-```bash
-pnpm add @std/http@jsr:^1.1.4
-```
+
+
+## 3. The server config
+
+
-Then the server entry:
+## 4. The server
```ts title="src/server.ts"
import { createStreamingHandler } from '@push-based/angular-ssr-stream-core/server';
@@ -76,12 +81,16 @@ and every request gets a fresh `Response` of it.
`allowedHosts` must list every hostname the server answers for: Angular's SSR
host guard rejects any other `host` header, and the server answers `403`.
+`Deno.serve()` listens on port 8000, Deno's default. To take the port from the
+environment, pass `{ port: Number(Deno.env.get('PORT') ?? 8000) }` as its first
+argument, and run Deno with `--allow-env`.
+
Paths in the server are relative to `import.meta.dirname`, the bundle's
folder, not to the working directory. Deno's `--allow-read` path is resolved
against the working directory, though, so it has to point at `dist` from
wherever the server is started.
-## 4. Vite
+## 5. Vite
```ts title="vite.config.ts"
import { ngp } from '@push-based/vite-plugin-ngp';
@@ -130,7 +139,7 @@ declare namespace Deno {
and add `deno.d.ts` to `include` in `tsconfig.app.json`. Deno itself has the
full declarations (`deno types`).
-## 5. Build and run
+## 6. Build and run
```bash
vite build
@@ -138,18 +147,13 @@ deno run --allow-net --allow-read=dist dist/server/server.js
```
The server listens on port 8000. It needs to read `dist` and to listen, and no
-other permission. Check that it streams:
+other permission.
-```bash
-curl -N http://localhost:8000/
-```
+## 7. Check that it streams
-The shell, with the widget's placeholder, arrives at once, and each `@defer`
-block follows in a `` chunk when its data is there. A
-response that arrives all at once means something buffered it; see
-[Debugging and verifying](../guides/debugging.md).
+
-### While developing
+## 8. Develop
There is no dev server that renders in Deno: `vite dev` renders on Node. Rebuild
on every change instead, and let Deno restart on every new build:
@@ -163,7 +167,11 @@ deno run --watch=dist/ --allow-net --allow-read=dist dist/server/server.js
the server bundle's own modules. There is no hot module replacement, and the
build is a production build, so Angular's dev-mode hydration checks are off.
-## 6. Deno Deploy
+## 9. Stream something
+
+
+
+## Deno Deploy
> [!WARNING]
> Deno Deploy shuts down in April 2027; see
@@ -219,7 +227,7 @@ encoder as it's written, and the shell still arrives at once.
> been run against a real Deno Deploy app, so check the result with
> `curl -N https:///` after the first deploy.
-## 7. Supabase Edge Functions
+## Supabase Edge Functions
Supabase Edge Functions run on Deno too, but they are built for APIs, not
pages, and in practice they can't serve this app:
@@ -246,7 +254,3 @@ Each of these has a workaround, but together they make Supabase a poor host
for a server-rendered app. Serve the pages from Deno Deploy or any host that
runs Deno, and call your Supabase functions from there. This section has not
been checked against Supabase.
-
-## 8. Stream something
-
-
diff --git a/apps/docs/src/content/getting-started/express.md b/apps/docs/src/content/getting-started/express.md
index 6ffd5b7..e99b25b 100644
--- a/apps/docs/src/content/getting-started/express.md
+++ b/apps/docs/src/content/getting-started/express.md
@@ -6,20 +6,26 @@ app's catch-all, after the browser build and the API routes, with
[`apps/example-express`](../../../../../apps/example-express/src/server.ts) in
the repository uses, on Express 5.
+## Before you start
+
+
+
+## 1. Install
+
```bash
npm install @push-based/angular-ssr-stream-core@next @push-based/angular-ssr-stream-node@next express compression
-npm install -D @types/express @types/compression
+npm install -D @types/node @types/express @types/compression
```
-## 1. The browser config
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The server
+## 4. The server
```ts title="src/server.ts"
import { fileURLToPath } from 'node:url';
@@ -112,14 +118,13 @@ The file is built to `dist/server/server.js`, so both URLs are relative to
that: the template is `dist/server/index.server.html`, and the browser build
is `dist/client`.
-`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the server answers `403`.
-Behind a proxy that rewrites the host, see
-[`trustProxy`](../reference/node.md#createnodehandler).
+
-`eventDispatchContract` is for `withEventReplay()`. The handler adds it to the
-template unless it's there already, so a click made before the page hydrates is
-queued and replayed.
+
+
+Behind a proxy that rewrites the host, see
+[`trustProxy`](../reference/node.md#createnodehandler). A `Host` header that
+can't be parsed at all is a `400`, passed to `next()` before the check.
The module default-exports the Express app, not the handler: in dev, the Vite
plugin calls that export for each page, so pages go through the same
@@ -157,7 +162,7 @@ trace whenever `NODE_ENV` isn't `production`. An error after the
first byte can't change the response any more: the handler cuts the
connection, and the error doesn't reach `next()`.
-## 4. Vite
+## 5. Vite
```ts title="vite.config.ts"
import { angularStreamNode } from '@push-based/angular-ssr-stream-node/vite';
@@ -190,7 +195,7 @@ sees it, so the API answers in dev as it does in production. `'/api'` matches
`/api` and `/api/hello`, not `/api.json`; list one prefix for each your API
routes use. In a build the plugin does nothing.
-## 5. Develop
+## 6. Develop
```bash
vite dev # http://localhost:5173
@@ -208,7 +213,7 @@ a route that picks pages by their path, such as `app.get('/admin',
requireLogin)`, only matches in production. Middleware that has to run for some pages in dev too
can be mounted without a path and read `req.originalUrl`.
-## 6. Build and run
+## 7. Build and run
```json title="package.json"
{
@@ -230,24 +235,14 @@ Vite left out of the bundle, so run it where the app's `node_modules` are, or
install the production dependencies next to `dist/` in your image. Angular is
bundled.
-## 7. Check that it streams, compressed
-
-Ask for the page the way a browser does, compressed, and time when the shell
-and the widget arrive:
+## 8. Check that it streams
-```bash
-curl -sN --compressed http://localhost:3000/ | perl -MTime::HiRes=time -ne '
- BEGIN { $t0 = time }
- printf "%5d ms %s\n", (time - $t0) * 1000, $& if /data-placeholder|
-```text
- 2 ms data-placeholder
- 2011 ms
diff --git a/apps/docs/src/content/getting-started/fastify.md b/apps/docs/src/content/getting-started/fastify.md
index a7424be..25bd190 100644
--- a/apps/docs/src/content/getting-started/fastify.md
+++ b/apps/docs/src/content/getting-started/fastify.md
@@ -5,21 +5,30 @@ and every other `GET` rendered as a streamed page by the `angularStream`
plugin. The plugin is built on the [Node adapter](node.md), and dev mode uses
its Vite plugin.
-## 1. The browser config
+## Before you start
-
-
-## 2. The server config
-
-
+
-## 3. The server
+## 1. Install
```bash
npm install @push-based/angular-ssr-stream-core@next @push-based/angular-ssr-stream-node@next @push-based/angular-ssr-stream-fastify@next
npm install fastify @fastify/static @fastify/compress
+npm install -D @types/node
```
+The Node adapter is for `vite dev`, through its Vite plugin.
+
+## 2. The browser config
+
+
+
+## 3. The server config
+
+
+
+## 4. The server
+
```ts title="src/server.ts"
import type { IncomingMessage, ServerResponse } from 'node:http';
import { fileURLToPath } from 'node:url';
@@ -111,20 +120,17 @@ wildcard it registers a route per file it finds at startup. `globIgnore`
leaves out `index.html`, which is the browser build's copy of the template and
would otherwise be served as `/index.html` and `/`, unrendered.
-`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the server answers `403`.
+
+
+
+
Behind a proxy that rewrites the host, see
[`trustProxy`](../reference/fastify.md#angularstream).
-`eventDispatchContract` is for `withEventReplay()`. The plugin adds it to the
-template unless it's there already, so a click made before the page hydrates is
-queued and replayed. Leave it out and those clicks are lost; the server logs a
-warning when that happens.
-
`@fastify/compress` has to be registered before the plugin, and needs
-`flushOnIdle: true`; see [7. Compression](#7-compression).
+`flushOnIdle: true`; see [9. Compression](#9-compression).
-## 4. Vite
+## 5. Vite
```ts title="vite.config.ts"
import { angularStreamNode } from '@push-based/angular-ssr-stream-node/vite';
@@ -163,7 +169,7 @@ the dev template on it. It restores `req.url` first: Vite has rewritten it to
port of its own, and `@fastify/static` isn't registered: Vite serves the
browser files.
-## 5. Develop
+## 6. Develop
```bash
vite dev # http://localhost:5173
@@ -182,7 +188,7 @@ An API outside `/api` needs its own prefix in `routes`. To check a page with
curl -sN -H 'Accept: text/html' http://localhost:5173/
```
-## 6. Build and run
+## 7. Build and run
```json title="package.json"
{
@@ -208,49 +214,28 @@ your image. Angular is bundled.
default. In a container, or anywhere the server must be reached from another
machine, listen on every interface with `app.listen({ port, host: '0.0.0.0' })`.
-Check that it streams before you put anything in front of it:
+## 8. Check that it streams
-```bash
-curl -sN -o /dev/null --trace-time --trace-ascii - http://localhost:3000/ | grep 'Recv data'
-```
+Before you put anything in front of the server:
-```text
-20:30:32.400163 <= Recv data, 3065 bytes (0xbf9)
-20:30:34.402703 <= Recv data, 812 bytes (0x32c)
-```
+
-That's the example: the shell at once, and the widget's chunk two seconds
-later, when its data is there. One line for the whole page means something
-buffered it; see
-[Checking that a response streams](../guides/streaming-through-proxies.md#checking-that-a-response-streams).
-
-## 7. Compression
+## 9. Compression
`@fastify/compress` compresses a page in an `onSend` hook, and by default
holds the compressed output until the page is complete. With
-`app.register(fastifyCompress)` alone, the example's page arrives in one piece
-when the widget is done:
+`app.register(fastifyCompress)` alone, the page arrives in one piece when the
+last block is done. Run the check with `--compressed` to see it:
```bash
-curl -sN --compressed http://localhost:3000/ | perl -MTime::HiRes=time -ne '
- BEGIN { $t0 = time }
- printf "%5d ms %s\n", (time - $t0) * 1000, $& if /data-placeholder|
diff --git a/apps/docs/src/content/getting-started/fastly-compute.md b/apps/docs/src/content/getting-started/fastly-compute.md
index 93e0087..098e3d8 100644
--- a/apps/docs/src/content/getting-started/fastly-compute.md
+++ b/apps/docs/src/content/getting-started/fastly-compute.md
@@ -12,11 +12,15 @@ every path without a file is rendered and streamed. This is the setup of
> later, and the page hydrates. It has not been checked against a real Fastly
> deployment yet.
+## Before you start
+
+
+
## 1. Install
```bash
-pnpm add @push-based/angular-ssr-stream-core@next @fastly/compute-js-static-publish
-pnpm add -D @fastly/js-compute
+npm install @push-based/angular-ssr-stream-core@next @fastly/compute-js-static-publish
+npm install -D @fastly/js-compute
```
`@fastly/js-compute` compiles the server bundle to Wasm (`js-compute-runtime`)
@@ -212,9 +216,7 @@ Four things here are for Compute:
`*.edgecompute.app` one included: Angular's SSR host guard rejects any other
`host` header, and the page answers `403`.
-`eventDispatchContract` is for `withEventReplay()`: the built `index.html`
-doesn't carry the script Angular needs to queue the clicks made before the page
-hydrates, so the handler adds it.
+
Don't open a KV Store, or anything else from `fastly:*`, at the top level of the
module. `js-compute-runtime` runs the module once at build time to snapshot it,
@@ -312,7 +314,7 @@ manifest_version = 3
name = "angular-ssr-stream-example"
[scripts]
-build = "pnpm run build && pnpm run compile"
+build = "npm run build && npm run compile"
[local_server.kv_stores]
example-content = { file = "./static-publisher/kvstore.json", format = "json" }
@@ -324,14 +326,20 @@ example-content = { file = "./static-publisher/kvstore.json", format = "json" }
static publisher writes locally. `[setup.kv_stores]` creates the real one on the
first deploy. Add `bin/`, `pkg/` and `static-publisher/` to `.gitignore`.
-## 8. Build and run it locally
+## 8. Develop
+
+There is no dev server that runs the server side: `vite dev` alone serves the
+app client-side, without SSR, and Angular logs NG0505 as there is no hydration
+data. To see it stream, build it and run it in Viceroy.
+
+## 9. Build and run it locally
The scripts in `package.json`:
```json title="package.json"
{
"scripts": {
- "build": "vp build",
+ "build": "vite build",
"compile": "js-compute-runtime dist/server/server.js bin/main.wasm",
"content:local": "compute-js-static-publish publish-content --local",
"start": "fastly compute serve --skip-build"
@@ -340,18 +348,22 @@ The scripts in `package.json`:
```
```bash
-pnpm build # dist/client and dist/server/server.js
-pnpm compile # bin/main.wasm
-pnpm content:local # dist/client into Viceroy's KV Store
-pnpm start # http://127.0.0.1:7676
+npm run build # dist/client and dist/server/server.js
+npm run compile # bin/main.wasm
+npm run content:local # dist/client into Viceroy's KV Store
+npm start # http://127.0.0.1:7676
```
-The browser app uses `vp`, Vite+'s CLI; `vite build` does the same. `compile`
-takes about 7 seconds. Publish the content again after each build, because the
-file names change, and restart Viceroy after a publish. There is no dev server
-that runs the server side: `vite dev` alone serves the app without SSR.
+`compile` takes about 7 seconds. Publish the content again after each build,
+because the file names change, and restart Viceroy after a publish.
+
+## 10. Check that it streams
+
+With Viceroy running:
+
+
-## 9. Deploy
+## 11. Deploy
> [!WARNING]
> Unverified: no real deployment has been made. These are the steps from
@@ -361,15 +373,21 @@ With the Fastly CLI logged in:
```bash
fastly compute publish
-FASTLY_API_TOKEN= pnpm exec compute-js-static-publish publish-content
+FASTLY_API_TOKEN= npx compute-js-static-publish publish-content
```
`fastly compute publish` runs the `build` script from `fastly.toml`, packages
`bin/main.wasm` and deploys it; the first time, it creates the service and the
-KV Store. `publish-content` then uploads `dist/client` to the store. It reads
-the token only from `FASTLY_API_TOKEN` or `--fastly-api-token`, not from the
-CLI's profile. After a new build, run both again, the content first: the new
-server expects the new file names.
+KV Store, which is why it comes first then. `publish-content` uploads
+`dist/client` to the store. It reads the token only from `FASTLY_API_TOKEN` or
+`--fastly-api-token`, not from the CLI's profile. On every later deploy, run
+them the other way round, the content first: the new server expects the new
+file names. Then check the service's `*.edgecompute.app` address the same way
+as Viceroy.
+
+## 12. Stream something
+
+
## Limits
@@ -392,7 +410,3 @@ cancels the response body, so the page renders to its end, and the instance
then exits with status 1: the log shows "JS event loop terminated without
completing the request" for every aborted request. Nothing is sent and nothing
else is affected, but the request still costs its full render.
-
-## Stream something
-
-
diff --git a/apps/docs/src/content/getting-started/hono.md b/apps/docs/src/content/getting-started/hono.md
index 63ff86d..b40827e 100644
--- a/apps/docs/src/content/getting-started/hono.md
+++ b/apps/docs/src/content/getting-started/hono.md
@@ -10,22 +10,28 @@ Node setup and
[`apps/example-hono-workers`](../../../../../apps/example-hono-workers/src/worker.ts)
the Workers one, as written here.
+## Before you start
+
+
+
+## Node
+
+### 1. Install
+
```bash
npm install @push-based/angular-ssr-stream-core@next hono @hono/node-server
-npm install -D @hono/vite-dev-server
+npm install -D @hono/vite-dev-server @types/node
```
-## Node
-
-### 1. The browser config
+### 2. The browser config
-### 2. The server config
+### 3. The server config
-### 3. The server
+### 4. The server
```ts title="src/server.ts"
import { readFile } from 'node:fs/promises';
@@ -101,14 +107,11 @@ instead of a page. Vite puts the build's hashed files there, so after a deploy
a browser still holding the old page asks for chunks that are gone; a page in
their place would fail to load as a script.
-`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the server answers `403`.
+
-`eventDispatchContract` is for `withEventReplay()`. The built `index.html`
-doesn't carry the script Angular needs to queue the clicks made before the page
-hydrates, so the handler adds it. Leave it out and those clicks are lost.
+
-### 4. Vite
+### 5. Vite
```ts title="vite.config.ts"
import devServer from '@hono/vite-dev-server';
@@ -133,10 +136,18 @@ Angular bundled in.
In `vite dev`, `@hono/vite-dev-server` loads `src/server.ts` through Vite and
hands it every request Vite doesn't serve itself, with the dev server as
`c.env.vite`. The template then comes from `transformIndexHtml`, which already
-adds Vite's client, so `injectClientScript` stays off. The page streams in dev
-as it does in production.
+adds Vite's client, so `injectClientScript` stays off.
-### 5. Build and run
+### 6. Develop
+
+```bash
+vite dev # http://localhost:5173
+```
+
+The page streams in dev as it does in production, and the API answers from
+the same app.
+
+### 7. Build and run
```bash
vite build # client to dist/client, server to dist/server
@@ -148,7 +159,11 @@ any working directory. Deploy `dist` with `node_modules`: the server bundle
includes Angular, and imports the rest of its dependencies, Hono among them,
from there.
-### 6. Stream something
+### 8. Check that it streams
+
+
+
+### 9. Stream something
diff --git a/apps/docs/src/content/getting-started/installation.md b/apps/docs/src/content/getting-started/installation.md
index 59e60ca..8bf5edf 100644
--- a/apps/docs/src/content/getting-started/installation.md
+++ b/apps/docs/src/content/getting-started/installation.md
@@ -110,6 +110,24 @@ version of each.
The packages ship ESM and type declarations, and carry no Angular decorators,
so they need no Angular compilation of their own.
+## Developing
+
+What the dev server does differs by runtime. Where it doesn't stream, it serves
+the app client-side: Angular renders it in the browser and logs NG0505, as
+there is no hydration data. Build and run it to see the stream there.
+
+| Runtime | Dev server | Streams in dev |
+| -------------------------------------------------------- | ------------------------------------------- | -------------------------- |
+| Angular CLI | `ng serve` | Yes |
+| Node, Express, Fastify, NestJS, Koa | `vite dev`, with the Node plugin | Yes |
+| Cloudflare Workers, Hono | `vite dev` | Yes |
+| Netlify, Nitro | `vite dev` | Yes |
+| Deno | `vite build --watch` and `deno run --watch` | Yes, as a production build |
+| Bun, Vercel, AWS Lambda, Azure Functions, Fastly Compute | `vite dev` | No: client-side only |
+| Service Worker | `vite dev` | No: client-side only |
+
+Each runtime's page has a "Develop" step with the details.
+
The hosted platforms (Vercel, Netlify, AWS Lambda, Azure Functions, Fastly
Compute, Deno Deploy, and Nitro's presets for them) have been checked locally,
with each platform's own tooling or a stand-in for it, but not yet on a real
diff --git a/apps/docs/src/content/getting-started/koa.md b/apps/docs/src/content/getting-started/koa.md
index 86a2c6f..666ca2d 100644
--- a/apps/docs/src/content/getting-started/koa.md
+++ b/apps/docs/src/content/getting-started/koa.md
@@ -8,22 +8,28 @@ Node adapter's Vite plugin for `vite dev`.
[`apps/example-koa`](../../../../../apps/example-koa/src/server.ts) in the
repository is this setup, as written here.
+## Before you start
+
+
+
+## 1. Install
+
```bash
npm install @push-based/angular-ssr-stream-core@next @push-based/angular-ssr-stream-node@next koa koa-static koa-compress
-npm install -D @types/koa @types/koa-static
+npm install -D @types/node @types/koa @types/koa-static
```
`koa-compress` 5.2 and later ship their own types.
-## 1. The browser config
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The server
+## 4. The server
```ts title="src/server.ts"
import type { IncomingMessage } from 'node:http';
@@ -182,7 +188,7 @@ stays in charge of the response:
- A logger or any other middleware around `page` sees the real status.
- `koa-compress` compresses the stream, and flushes each chunk with the
- options above (see [Compression](#7-compression)).
+ options above (see [Compression](#9-compression)).
- An error thrown before the response starts goes through Koa's error
handling, and your own `try`/`catch` middleware if you have one: a
`BadRequestError` becomes a `400`, anything else a `500`.
@@ -200,12 +206,9 @@ itself and passes a Node stream.
### The rest of the server
-`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the server answers `403`.
+
-`eventDispatchContract` is for `withEventReplay()`. The renderer adds it to
-the template unless it's there already, so a click made before the page
-hydrates is queued and replayed.
+
`page` renders every `GET` and `HEAD` that reaches it, so mount whatever
answers those first: API routes, like `/api/hello` here, and `koa-static`.
@@ -224,7 +227,7 @@ too, and after the API routes, so a file can't shadow one. A missing file
under `/assets/`, such as an old hashed chunk after a deploy, gets a `404`;
any other path that isn't a file falls through to `page` and is rendered.
-## 4. Vite
+## 5. Vite
```ts title="vite.config.ts"
import { angularStreamNode } from '@push-based/angular-ssr-stream-node/vite';
@@ -259,7 +262,7 @@ header, before Vite sees it, so `/api/hello` answers in dev as it does in
production. It matches `/api` and `/api/hello`, not `/api.json`; list one
prefix for each your API uses.
-## 5. Develop
+## 6. Develop
```bash
vite dev # http://localhost:5173
@@ -270,7 +273,7 @@ and any other middleware in front of `page`, and `/api/hello` is answered by
the same app. `import.meta.env.PROD` is `false` there, so `src/server.ts`
neither mounts `koa-static` nor starts a server of its own.
-## 6. Build and run
+## 7. Build and run
```json title="package.json"
{
@@ -292,49 +295,31 @@ leaves out of the bundle, so run it where the app's `node_modules` are, or
install the production dependencies next to `dist/` in your image. Angular is
bundled.
-Check that it streams before you put anything in front of it:
+## 8. Check that it streams
-```bash
-curl -sN -o /dev/null --trace-time --trace-ascii - http://localhost:3000/ | grep 'Recv data'
-```
+Before you put anything in front of the server:
-```text
-20:25:40.944026 <= Recv data, 3057 bytes (0xbf1)
-20:25:42.949025 <= Recv data, 788 bytes (0x314)
-20:25:42.949179 <= Recv data, 19 bytes (0x13)
-20:25:42.949415 <= Recv data, 5 bytes (0x5)
-```
-
-That's the example: the shell at once, and two seconds later the widget's
-chunk, followed by the end of the page and the closing chunk. One line for the
-whole page means something buffered it; see
-[Checking that a response streams](../guides/streaming-through-proxies.md#checking-that-a-response-streams).
+
-## 7. Compression
+## 9. Compression
`koa-compress` passes the body through a zlib stream, and a zlib stream holds
its output until it has enough to compress well. For a page, that is all of
it. Without the `flush` options, `app.use(compress())` sends the shell
-compressed, but only when the last block is done:
+compressed, but only when the last block is done. Run the check with
+`--compressed` and the whole page arrives at the end:
```bash
-curl -sN --compressed http://localhost:3000/ | perl -MTime::HiRes=time -ne '
- BEGIN { $t0 = time }
- printf "%5d ms %s\n", (time - $t0) * 1000, $& if /data-placeholder|
diff --git a/apps/docs/src/content/getting-started/nestjs.md b/apps/docs/src/content/getting-started/nestjs.md
index 808a4dc..18e59dc 100644
--- a/apps/docs/src/content/getting-started/nestjs.md
+++ b/apps/docs/src/content/getting-started/nestjs.md
@@ -8,15 +8,27 @@ On `@nestjs/platform-fastify`, only the server entry, compression and static
files change; [Fastify](#fastify) has those, and `apps/example-nestjs-fastify`
is that setup.
-## 1. The browser config
+## Before you start
+
+
+
+## 1. Install
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next @push-based/angular-ssr-stream-nestjs@next \
+ @nestjs/common @nestjs/core @nestjs/platform-express reflect-metadata
+npm install -D @types/node
+```
+
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The Nest module
+## 4. The Nest module
Import `AngularStreamModule` into your root module, next to your controllers:
@@ -54,7 +66,10 @@ template is `dist/server/index.server.html`, and `staticDir` is the browser
build in `dist/client`.
`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the server answers `403`.
+host guard rejects any other `host` header, and the server answers `403`. A
+`Host` header that is more than a host and a port is a `400`; see
+[What Nest sees of a page](#12-what-nest-sees-of-a-page).
+`eventDispatchContract` is as on [Node](node.md#4-the-server).
The controller is an ordinary Nest controller:
@@ -77,7 +92,7 @@ When the options come from somewhere else, such as `ConfigService`, use
`AngularStreamModule.forRootAsync({ imports, useFactory, inject })`; see
[the reference](../reference/nestjs.md#angularstreammoduleforrootasync).
-## 4. The server entry
+## 5. The server entry
```ts title="src/server.ts"
import 'reflect-metadata';
@@ -112,7 +127,7 @@ controller takes is rendered.
`createRequestListener()` turns the app into a `node:http` request listener for
`vite dev`. In production, `app.listen()` starts the server as usual.
-## 5. TypeScript
+## 6. TypeScript
Nest reads constructor types from decorator metadata, so the tsconfig the app
is built with needs both decorator flags:
@@ -135,7 +150,7 @@ warns at startup that `HelloController` "has no decorator metadata", passes
`AngularStreamModule` itself is published without decorators, so it works
however your app compiles them.
-## 6. Vite
+## 7. Vite
```ts title="vite.config.ts"
import { angularStreamNest } from '@push-based/angular-ssr-stream-nestjs/vite';
@@ -161,7 +176,7 @@ transforms it, and sends it every other request Vite has no file or module for,
so `/api/hello` reaches Nest in dev too. List it before ngp. In a build it does
nothing.
-## 7. Develop
+## 8. Develop
```bash
vite dev # http://localhost:5173
@@ -171,7 +186,7 @@ Pages stream as they do in production, the API answers, and an edit to a
controller or service is live on the next request. `import.meta.env.PROD` is
`false` there, so `src/server.ts` doesn't call `listen()`.
-## 8. Build and run
+## 9. Build and run
```json title="package.json"
{
@@ -192,23 +207,11 @@ node dist/server/server.js # http://localhost:3000, or $PORT
Vite left out of the bundle, so run it where the app's `node_modules` are, or
install the production dependencies next to `dist/` in your image.
-Check that it streams:
-
-```bash
-curl -sN -o /dev/null --trace-time --trace-ascii - http://localhost:3000/ | grep 'Recv data'
-```
-
-```text
-20:36:36.798526 <= Recv data, 3063 bytes (0xbf7)
-20:36:38.800019 <= Recv data, 807 bytes (0x327)
-```
+## 10. Check that it streams
-That's the example: the shell at once, and the widget's chunk two seconds
-later, when its data is there. One line for the whole page means something
-buffered it; see
-[Checking that a response streams](../guides/streaming-through-proxies.md#checking-that-a-response-streams).
+
-## 9. Static files
+## 11. Static files
`staticDir` serves the browser build from the render route: a file in
`dist/client` is sent from disk, anything else is rendered. A path that
@@ -224,7 +227,9 @@ app.useStaticAssets(fileURLToPath(new URL('../client/', import.meta.url)), { ind
```
`index: false` matters: without it, `/` gets the unrendered `index.html` from
-the browser build. `/index.html` itself is still served from disk as it is.
+the browser build. `/index.html` itself is still served from disk as it is, the
+bare template, where every other setup on these pages renders it. `staticDir`
+doesn't have that gap.
`ServeStaticModule` from `@nestjs/serve-static` answers every `GET` it can't
find a file for with its own `index.html`, which leaves nothing for the Angular
@@ -251,7 +256,7 @@ route, whatever `exclude` says, and Fastify refuses to start with two
catch-all routes (`FST_ERR_DUPLICATED_ROUTE`). Use `staticDir` or
`@fastify/static` there; see [Fastify](#fastify).
-## 10. What Nest sees of a page
+## 12. What Nest sees of a page
Pages aren't controller routes. The render route is added after everything
else, so Nest's guards, interceptors and pipes never run for a page, and
@@ -275,7 +280,7 @@ render, and only if that fails too does the error reach the filters, as a
cuts the connection, so the browser keeps what it has and no filter writes a
JSON body into the page.
-## 11. Behind a proxy
+## 13. Behind a proxy
A proxy, a CDN or compression middleware can hold the response back until it
is complete. Pages carry `X-Accel-Buffering: no` for Nginx, and `compression`
@@ -284,7 +289,7 @@ read [Streaming through proxies](../guides/streaming-through-proxies.md).
Behind a proxy that rewrites the host, set
[`trustProxy`](../reference/node.md#createnodehandler).
-## 12. Stream something
+## 14. Stream something
@@ -293,7 +298,7 @@ Behind a proxy that rewrites the host, set
The same module renders pages on `@nestjs/platform-fastify`, with the same
options and the same results: the API keeps `/api`, an unknown `/api/...`
gets Nest's `404`, a missing file under `/assets/` is a `404`, and a bad
-`Host` is a `400`. Every step but static files (step 9) stays the same.
+`Host` is a `400`. Every step but static files stays the same.
Install the Nest adapter, the stream's Fastify adapter, which the module loads
only on Fastify, and `@fastify/compress` if you compress in Node:
diff --git a/apps/docs/src/content/getting-started/netlify.md b/apps/docs/src/content/getting-started/netlify.md
index 13225c2..bedcae9 100644
--- a/apps/docs/src/content/getting-started/netlify.md
+++ b/apps/docs/src/content/getting-started/netlify.md
@@ -6,15 +6,28 @@ function, which streams the page. The setup below is the one
uses. There is no Netlify package: the function is
`createStreamingHandler()` from the core, and the rest is build configuration.
-## 1. The browser config
+## Before you start
+
+
+
+## 1. Install
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next
+npm install -D @types/node @netlify/functions netlify-cli
+```
+
+`@netlify/functions` is only needed for its types.
+
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The function
+## 4. The function
A Netlify Function takes a web `Request` and a `Context` and returns a
`Response`, which is what `createStreamingHandler()` is. Netlify streams a
@@ -67,9 +80,7 @@ included: Angular's SSR host guard rejects any other `host` header, and the
function answers `403`. `*.netlify.app` covers the site's Netlify address and
its deploy previews.
-`eventDispatchContract` is for `withEventReplay()`: the built `index.html`
-doesn't carry the script Angular needs to queue the clicks made before the page
-hydrates, so the handler adds it.
+
The template is the built `index.html`, as a string inside the function
(`virtual:template`, below). Nothing is read from disk or fetched per request,
@@ -83,15 +94,13 @@ declare module 'virtual:template' {
}
```
-`@netlify/functions` is only needed for its types: `pnpm add -D @netlify/functions`.
-
> [!NOTE]
> `netlify serve` (netlify-cli 27.20.1) ignores a Netlify Function's
> `excludedPath`, so locally `/assets/missing.js` is rendered as a page. The
> excluded paths are in the function's manifest, and `netlify deploy` uploads
> them with it.
-## 4. Vite
+## 5. Vite
Netlify doesn't run Vite, so the build has to hand it a function it can deploy
as it is: one module, with Angular compiled and every dependency bundled in.
@@ -271,72 +280,82 @@ declare module 'virtual:public-paths' {
}
```
-## 5. netlify.toml
+## 6. netlify.toml
```toml title="netlify.toml"
[build]
-command = "pnpm nx build example-netlify"
-publish = "apps/example-netlify/dist/function/client"
+command = "npm run build"
+publish = "dist/function/client"
[build.environment]
NODE_VERSION = "26"
[functions]
-directory = "apps/example-netlify/dist/function/netlify/functions"
+directory = "dist/function/netlify/functions"
```
-The example lives in a pnpm workspace, so the site's base directory is the
-repository root, where the workspace installs, and its package directory is
-`apps/example-netlify`, where `netlify.toml` is. Paths in it are relative to the
-base directory. In a repository with one app at its root, they are
-`dist/function/client` and `dist/function/netlify/functions`, and the command is
-`vite build`. The example's `build` script builds both variants, so its
-command builds the Edge Function too. `netlify.toml` names only the
+with `"build": "vite build"` in `package.json`. `netlify.toml` names only the
Function's folders, so only the Function is deployed.
-`NODE_VERSION` is the Node.js version the build runs on. Netlify installs any
-version nvm can, and defaults to Node.js 24
+`NODE_VERSION` is the Node.js version the build runs on, which ngp needs to
+be 26. Netlify installs any version nvm can, and defaults to Node.js 24
([Manage dependencies](https://docs.netlify.com/build/configure-builds/manage-dependencies/)).
-This workspace needs 26. The function then runs on the build's version if AWS
-Lambda offers it as a runtime, and on Node.js 24 otherwise
+The function then runs on the build's version if AWS Lambda offers it as a
+runtime, and on Node.js 24 otherwise
([Functions configuration](https://docs.netlify.com/build/functions/configuration/)).
The bundled function streams the same under Node.js 24.
-## 6. Build and deploy
+In a monorepo, the site's base directory is the repository root, where the
+workspace installs, and its package directory is the app's folder, where
+`netlify.toml` is. Paths in it are then relative to the base directory
+(`apps/my-app/dist/function/client`), and the command builds the app from the
+root. The package directory can only be set in the Netlify UI:
+**Project configuration > Developer settings > Continuous deployment > Build
+settings > Package directory**. Netlify reads `netlify.toml` from the package
+directory, then the base directory, then the repository root
+([Monorepos](https://docs.netlify.com/build/configure-builds/monorepos/)), so
+without it the build never reads the app's `netlify.toml`.
+[`apps/example-netlify/netlify.toml`](../../../../../apps/example-netlify/netlify.toml)
+is set up that way.
+
+## 7. Develop
```bash
-pnpm nx build example-netlify # dist/function (and dist/edge, the Edge Function)
-netlify serve --filter example-netlify
+vite dev # http://localhost:5173
```
-`netlify serve` runs the build command, packages the function the way a deploy
-does, and serves the result on `http://localhost:8888`, without an account or a
-linked site. It is the closest local check of what Netlify will run.
+The plugin in the Vite config hands each page to the function, so pages stream
+in dev as they do on Netlify.
-To deploy from the command line, run this at the repository root:
+## 8. Build and deploy
```bash
-netlify deploy --build --filter example-netlify
+vite build # dist/function: the browser app and the function
+netlify serve # http://localhost:8888
```
-`--filter` picks the app's package directory, as for `netlify serve`. A site
-built by Netlify from the repository needs its package directory as well, and
-that can only be set in the Netlify UI: **Project configuration > Developer
-settings > Continuous deployment > Build settings > Package directory**, set to
-`apps/example-netlify`. Netlify reads `netlify.toml` from the package directory,
-then the base directory, then the repository root
-([Monorepos](https://docs.netlify.com/build/configure-builds/monorepos/)).
-Without the package directory, the build never reads
-`apps/example-netlify/netlify.toml`.
+`netlify serve` runs the build command, packages the function the way a deploy
+does, and serves the result, without an account or a linked site. It is the
+closest local check of what Netlify will run. To deploy from the command line:
-> [!NOTE]
-> The example streams under `netlify serve`: the shell arrives at once and the
-> widget's chunk about 2 s later. It hasn't been timed against a deployed site
-> yet, so whether anything between Netlify's CDN and the browser buffers the
-> response is still open. Check with `curl -N` against your deploy, as
-> [Debugging and verifying](../guides/debugging.md) describes.
+```bash
+netlify deploy --build
+```
+
+In a monorepo, run both at the repository root with `--filter `,
+which picks the app's package directory.
+
+## 9. Check that it streams
+
+With `netlify serve` running:
+
+
+
+The example streams under `netlify serve`. It hasn't been timed against a
+deployed site yet, so whether anything between Netlify's CDN and the browser
+buffers the response is still open: run the same command against your deploy.
-## 7. Stream something
+## 10. Stream something
@@ -396,9 +415,9 @@ What changes:
```toml title="netlify.toml"
[build]
- command = "pnpm nx build example-netlify"
- publish = "apps/example-netlify/dist/edge/client"
- edge_functions = "apps/example-netlify/dist/edge/netlify/edge-functions"
+ command = "vite build --mode edge"
+ publish = "dist/edge/client"
+ edge_functions = "dist/edge/netlify/edge-functions"
[build.environment]
NODE_VERSION = "26"
@@ -417,4 +436,4 @@ What changes:
default; choose the edge when the page renders well within it.
`@netlify/edge-functions` is only needed for its types:
-`pnpm add -D @netlify/edge-functions`.
+`npm install -D @netlify/edge-functions`.
diff --git a/apps/docs/src/content/getting-started/nitro.md b/apps/docs/src/content/getting-started/nitro.md
index 17f5a60..fd2ad83 100644
--- a/apps/docs/src/content/getting-started/nitro.md
+++ b/apps/docs/src/content/getting-started/nitro.md
@@ -9,6 +9,10 @@ It needs Nitro 3, whose Vite plugin is what builds the server here. Nitro 3 is a
single host that has its own adapter, such as
[Cloudflare Workers](cloudflare-workers.md), that adapter is lighter.
+## Before you start
+
+
+
## 1. Install
```bash
@@ -47,8 +51,8 @@ This file is Nitro's server entry: Nitro serves a static file when there is
one, runs any routes of its own, and hands every other request to the handler,
which renders the route into the template.
-`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the handler answers `403`.
+
+
Nitro's server ignores `X-Forwarded-Host` and `X-Forwarded-Proto` unless its
`trustProxy` option is on, so behind a proxy the check sees the `host` header
the proxy sends. List preview hostnames too, with a wildcard such as
@@ -57,9 +61,7 @@ the proxy sends. List preview hostnames too, with a wildcard such as
A missing file under `/assets/` answers `404`; any other path that isn't a
file, `/nope.png` included, is rendered as a page.
-`eventDispatchContract` is for `withEventReplay()`. The built `index.html`
-doesn't carry the script Angular needs to queue the clicks made before the page
-hydrates, so the handler adds it.
+
## 5. Vite
@@ -90,10 +92,17 @@ server asset, which Nitro bundles into the server for every preset. In
`vite dev` it gives the handler the `index.html` Vite serves, with Vite's dev
transforms, so SSR behaves as it does in production.
-## 6. Run it
+## 6. Develop
+
+```bash
+vite dev # http://localhost:3000
+```
+
+Pages are rendered by the handler and stream as they do in production.
+
+## 7. Build and run
```bash
-vite dev # http://localhost:3000
vite build # node-server preset, to .output/
node .output/server/index.mjs # http://localhost:3000
```
@@ -102,7 +111,11 @@ node .output/server/index.mjs # http://localhost:3000
`.output/server`. The `node-server` output is self-contained: copy `.output`
anywhere Node runs. `vite preview` serves it too.
-## 7. Deploy with a preset
+## 8. Check that it streams
+
+
+
+## 9. Deploy with a preset
The preset decides what `vite build` writes. Set it with `NITRO_PRESET`, or
`preset` in the Nitro options:
@@ -115,7 +128,12 @@ NITRO_PRESET=bun vite build # bun .output/server/index.mjs
On Vercel and Netlify there is nothing to set: Nitro sees it is building there
and picks the preset itself, so a build command of `vite build` is enough.
-[Nitro's deploy docs](https://nitro.build/deploy) cover each provider.
+[Nitro's deploy docs](https://nitro.build/deploy) cover each provider. Run
+the check above against the deployment, too.
+
+## 10. Stream something
+
+
## Presets we checked
@@ -156,7 +174,3 @@ way with less in between. What it doesn't give you is the build: it has no
presets and no Vite plugin, so serving the client build, loading the template
and bundling the server would be yours to wire up. Use Nitro to reach the hosts
it has presets for, and a dedicated adapter where one host matters on its own.
-
-## Stream something
-
-
diff --git a/apps/docs/src/content/getting-started/node.md b/apps/docs/src/content/getting-started/node.md
index b5e65a8..8d0a104 100644
--- a/apps/docs/src/content/getting-started/node.md
+++ b/apps/docs/src/content/getting-started/node.md
@@ -4,15 +4,26 @@ browser build served from disk by the same handler, and every other request
rendered as a streamed page. The handler is also Connect and Express
middleware, so the same steps hold for a server built on those.
-## 1. The browser config
+## Before you start
+
+
+
+## 1. Install
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next @push-based/angular-ssr-stream-node@next
+npm install -D @types/node
+```
+
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The server
+## 4. The server
```ts title="src/server.ts"
import { createServer } from 'node:http';
@@ -45,15 +56,13 @@ The file is built to `dist/server/server.js`, so both URLs are relative to
that: the template is `dist/server/index.server.html`, and `staticDir` is the
browser build in `dist/client`.
-`allowedHosts` must list every hostname the server answers for: Angular's SSR
-host guard rejects any other `host` header, and the server answers `403`.
-Behind a proxy that rewrites the host, see
-[`trustProxy`](../reference/node.md#createnodehandler).
+
-`eventDispatchContract` is for `withEventReplay()`. The handler adds it to the
-template unless it's there already, so a click made before the page hydrates is
-queued and replayed. Leave it out and those clicks are lost; the server logs a
-warning when that happens.
+
+
+Behind a proxy that rewrites the host, see
+[`trustProxy`](../reference/node.md#createnodehandler). A `Host` header that
+can't be parsed at all is answered with `400`, before the check.
`staticDir` serves the browser build's files: scripts, styles, icons. A
request for anything else, `/` and `/index.html` included, is rendered as a
@@ -69,7 +78,7 @@ the app rather than the handler then; see
The whole Express setup, with `express.static()`, API routes and
`compression`, is on [Express](express.md).
-## 4. Vite
+## 5. Vite
```ts title="vite.config.ts"
import { angularStreamNode } from '@push-based/angular-ssr-stream-node/vite';
@@ -96,7 +105,7 @@ streams as it does in production. List it before ngp, or the dev server
refuses to start: ngp's own dev SSR would otherwise answer page requests first,
and call the handler the wrong way. In a build the plugin does nothing.
-## 5. Develop
+## 6. Develop
```bash
vite dev # http://localhost:5173
@@ -106,7 +115,7 @@ The dev server serves the sources, and every page is rendered by your handler
and streamed. `import.meta.env.PROD` is `false` there, so `src/server.ts`
doesn't start a server of its own.
-## 6. Build and run
+## 7. Build and run
```json title="package.json"
{
@@ -127,23 +136,13 @@ node dist/server/server.js # http://localhost:3000, or $PORT
bundle, so run it where the app's `node_modules` are, or install the
production dependencies next to `dist/` in your image. Angular is bundled.
-Check that it streams before you put anything in front of it:
-
-```bash
-curl -sN -o /dev/null --trace-time --trace-ascii - http://localhost:3000/ | grep 'Recv data'
-```
+## 8. Check that it streams
-```text
-19:52:21.629836 <= Recv data, 3059 bytes (0xbf3)
-19:52:23.629224 <= Recv data, 807 bytes (0x327)
-```
+Before you put anything in front of the server:
-That's the example: the shell at once, and the widget's chunk two seconds
-later, when its data is there. One line for the whole page means something
-buffered it; see
-[Checking that a response streams](../guides/streaming-through-proxies.md#checking-that-a-response-streams).
+
-## 7. Behind a proxy
+## 9. Behind a proxy
A proxy, a CDN or compression middleware can hold the response back until it
is complete, and the page then arrives all at once. The handler sends
@@ -151,6 +150,6 @@ is complete, and the page then arrives all at once. The handler sends
`compression`; for the rest, read
[Streaming through proxies](../guides/streaming-through-proxies.md).
-## 8. Stream something
+## 10. Stream something
diff --git a/apps/docs/src/content/getting-started/vercel.md b/apps/docs/src/content/getting-started/vercel.md
index 9b02d7f..9ba8a6f 100644
--- a/apps/docs/src/content/getting-started/vercel.md
+++ b/apps/docs/src/content/getting-started/vercel.md
@@ -11,15 +11,26 @@ writes the deployment itself, in the layout of Vercel's
> and run locally through Vercel's own Node.js launcher, where it streams; see
> [What has been checked](#what-has-been-checked).
-## 1. The browser config
+## Before you start
+
+
+
+## 1. Install
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next
+npm install -D @types/node vercel
+```
+
+## 2. The browser config
-## 2. The server config
+## 3. The server config
-## 3. The function
+## 4. The function
```ts title="src/function.ts"
import { readFile } from 'node:fs/promises';
@@ -50,12 +61,12 @@ server bundle: the built `index.html` with the script `withEventReplay()` needs,
so the handler takes no `eventDispatchContract`. The build below copies it into
the function, and the function reads it once per instance.
-`allowedHosts` must list every hostname the function answers for: Angular's SSR
-host guard rejects any other `host` header, and the function answers `403`.
+
+
Each preview deployment has its own `*.vercel.app` hostname; `'*.vercel.app'`
admits all of them, and the example lists that.
-## 4. Vite
+## 5. Vite
```ts title="vite.config.ts"
import { cp, mkdir, rm, writeFile } from 'node:fs/promises';
@@ -156,7 +167,16 @@ Vercel would serve it for `/` before the function ever saw the request.
Add `.vercel/` to `.gitignore`.
-## 5. Build and deploy
+## 6. Develop
+
+```bash
+vite dev # http://localhost:5173
+```
+
+`vite dev` serves the app client-side, without a server render, and Angular
+logs NG0505 because there is no hydration data. Nothing streams until the build.
+
+## 7. Build and deploy
Create a Vercel project for the app (in a monorepo, set its Root Directory to
the app's folder). Vercel runs the app's `build` script, finds the
@@ -168,8 +188,15 @@ vercel build # runs the build script; .vercel/output is the result
vercel deploy --prebuilt # uploads .vercel/output
```
-`vite dev` serves the app client-side, without a server render, and Angular
-logs NG0505 because there is no hydration data. Nothing streams until the build.
+## 8. Check that it streams
+
+Against the deployment's address:
+
+
+
+## 9. Stream something
+
+
## The Edge runtime
@@ -211,7 +238,3 @@ In this repository, with `apps/example-vercel`:
Not checked: a real deployment. Vercel's CDN, its compression and its routing
in front of the function have not been seen streaming this app.
-
-## Stream something
-
-
diff --git a/apps/docs/src/content/guides/service-worker.md b/apps/docs/src/content/guides/service-worker.md
index ba96842..404e1ad 100644
--- a/apps/docs/src/content/guides/service-worker.md
+++ b/apps/docs/src/content/guides/service-worker.md
@@ -30,7 +30,10 @@ Nothing in step 3 touches the network, so it works offline.
## Try it
+In a checkout of the repository:
+
```bash
+pnpm install
pnpm nx build example-service-worker
cd apps/example-service-worker && pnpm exec vp preview
```
@@ -41,14 +44,27 @@ which is the worker here. Then stop `vp preview`, or tick _Offline_
in DevTools, and reload again. The shell still comes at once and the widget
2 s later.
-`vp dev` serves the app client-rendered only: the worker is part of the build,
-and `main.ts` registers it in production builds only.
+In your own app, `vite build` and `vite preview` do the same. `vite dev` serves
+the app client-rendered only: the worker is part of the build, and `main.ts`
+registers it in production builds only.
## The setup
-The browser config and the server config are the ones every runtime uses; see
-steps 1 and 2 of [Cloudflare Workers](../getting-started/cloudflare-workers.md).
-What differs is the worker, its registration and the build.
+
+
+```bash
+npm install @push-based/angular-ssr-stream-core@next
+```
+
+### The browser config
+
+
+
+### The server config
+
+
+
+What differs from a server is the worker, its registration and the build.
### The worker
@@ -266,3 +282,7 @@ cache of its own: Angular's cache names are internal, and the worker can't
server: the server's first byte is as fast, and the worker adds 142 kB and a
second place where the app renders. Nor does it help the first visit, search
engines or link previews.
+
+## Stream something
+
+
diff --git a/apps/docs/src/content/guides/streaming-through-proxies.md b/apps/docs/src/content/guides/streaming-through-proxies.md
index f5cf0fb..4f08ae8 100644
--- a/apps/docs/src/content/guides/streaming-through-proxies.md
+++ b/apps/docs/src/content/guides/streaming-through-proxies.md
@@ -56,7 +56,7 @@ it.
every chunk, so `app.use(compression())` in front of the handler streams
compressed pages with nothing more to do. Without the flush, the same
response arrives in one piece when the last block is done.
- [Express](../getting-started/express.md#7-check-that-it-streams-compressed)
+ [Express](../getting-started/express.md#compressed)
shows where it goes among the other middleware, both responses as `curl`
sees them, and how to leave pages out of it.
- **Other middleware built on Node's `zlib`** (`@fastify/compress`,
@@ -76,7 +76,7 @@ it.
`BROTLI_OPERATION_FLUSH` for `br` and `ZSTD_e_flush` for `zstd`. Version
5.3 prefers zstd, which Chrome asks for, so leave none out. The setup, and
the timings with and without it, are in
- [Koa](../getting-started/koa.md#7-compression).
+ [Koa](../getting-started/koa.md#9-compression).
- **Other middleware built on Node's `zlib`** (`@fastify/compress` and
others) has to flush after each write as well. zlib does that when the
stream is created with `flush: zlib.constants.Z_SYNC_FLUSH` (Brotli:
diff --git a/apps/docs/src/content/reference/nestjs.md b/apps/docs/src/content/reference/nestjs.md
index f0cb37a..89ce991 100644
--- a/apps/docs/src/content/reference/nestjs.md
+++ b/apps/docs/src/content/reference/nestjs.md
@@ -304,7 +304,7 @@ The package is published without decorators: the module is a
whatever compiles the app's own decorators. The app's controllers and
services need `experimentalDecorators` and `emitDecoratorMetadata`, which
Vite's transform reads from the tsconfig; see
-[TypeScript](../getting-started/nestjs.md#5-typescript).
+[TypeScript](../getting-started/nestjs.md#6-typescript).
## Other platforms