From 92dcf81c17d7145bbd5f6e1d731bb9cb84a146d7 Mon Sep 17 00:00:00 2001 From: Edvinas Jurele <73230019+edv-ns@users.noreply.github.com> Date: Tue, 7 Feb 2023 20:58:37 +0200 Subject: [PATCH] update node integration README with Fastify code example (#6120) --- packages/integrations/node/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/integrations/node/README.md b/packages/integrations/node/README.md index 11a9d97f13..3eb8d1caf0 100644 --- a/packages/integrations/node/README.md +++ b/packages/integrations/node/README.md @@ -98,6 +98,27 @@ app.use(ssrHandler); app.listen(8080); ``` +Or, with Fastify (>4): + +```js +import Fastify from 'fastify'; +import fastifyMiddie from '@fastify/middie'; +import fastifyStatic from '@fastify/static'; +import { fileURLToPath } from 'url'; +import { handler as ssrHandler } from './dist/server/entry.mjs'; + +const app = Fastify({ logger: true }); + +await app + .register(fastifyStatic, { + root: fileURLToPath(new URL('./dist/client', import.meta.url)), + }) + .register(fastifyMiddie); +app.use(ssrHandler); + +app.listen({ port: 8080 }); +``` + Note that middleware mode does not do file serving. You'll need to configure your HTTP framework to do that for you. By default the client assets are written to `./dist/client/`. ### Standalone