+stream
boolean | 'web' | 'node'
false (or true if using a Vike extension that requires streaming)ssr: truevike-react/vike-vue/vike-solidYou need
vike-react/vike-vue/vike-solidto be able to use thestreamsetting. If you don't usevike-{react,vue,solid}then see Withoutvike-{react,vue,solid}.
The stream setting allows you to:
- Enable or disable HTML Streaming.
- Specify the stream type (either a Node.js Stream or a Web Stream).
What is HTML Streaming? If you're unfamiliar with HTML streaming then check out this explanation of SSR, HTML streaming, and Progressive Rendering. Although it explains it in the context of React, we also recommend reading it if you use a UI framework other than React.
// /pages/+config.js
export default {
// Enable HTML Streaming. Let Vike extensions decide whether to use a Node.js or Web stream.
stream: true,
// Enable HTML Streaming. Force the stream to be a Web Stream.
stream: 'web',
// Enable HTML Streaming. Force the stream to be a Node.js Stream.
stream: 'node'
}// /pages/+config.ts
import type { Config } from 'vike/types'
export default {
// Enable HTML Streaming. Let Vike extensions decide whether to use a Node.js or Web stream.
stream: true,
// Enable HTML Streaming. Force the stream to be a Web Stream.
stream: 'web',
// Enable HTML Streaming. Force the stream to be a Node.js Stream.
stream: 'node'
} satisfies ConfigWhy doesn't it seem to work? If you enable HTML Streaming but the HTML is still sent all at once, note that:
- The
+datahook doesn't trigger HTML Streaming — the+datahook applies to the whole page and is fully awaited before rendering starts. A slow+datahook still results in the HTML being sent all at once. To see HTML streaming in action, use a Vike extension likevike-react-query/vike-vue-query/vike-solid-query(and the upcoming Telefunc integrations such asvike-react-telefunc).- By default, HTML streaming is disabled for bots. For example, the
User-Agentheader sent bycurlis interpreted as a bot. Seereact-streaming> Bots.
Inheritance
Enable for all your pages:
// /pages/+config.js
// This config applies to all pages (/pages/**).
export default {
stream: false
}// /pages/+config.ts
import type { Config } from 'vike/types'
// This config applies to all pages (/pages/**).
export default {
stream: false
} satisfies ConfigEnable only for some pages:
// /pages/admin/+config.js
/* This config applies only to admin pages (/pages/admin/**) such as:
FILESYSTEM URL
/pages/admin/+Page.js /admin
/pages/admin/user/@id/+Page.js /admin/user/@id
/pages/admin/product/@id/+Page.js /admin/product/@id
*/
export default {
stream: false
}// /pages/admin/+config.ts
import type { Config } from 'vike/types'
/* This config applies only to admin pages (/pages/admin/**) such as:
FILESYSTEM URL
/pages/admin/+Page.ts /admin
/pages/admin/user/@id/+Page.ts /admin/user/@id
/pages/admin/product/@id/+Page.ts /admin/product/@id
*/
export default {
stream: false
} satisfies ConfigFor better config organization, you can use page groups.
Without vike-{react,vue,solid}
In case you don't use a UI framework Vike extension vike-react/vike-vue/vike-solid, you can:
- Integrate HTML streaming yourself, see HTML Streaming.
- Implement the
streamsetting yourself by using meta. Examples:
See also
- HTML Streaming
-
API >
+ssr - Explanation of SSR, HTML streaming, and Progressive Rendering
- Node.js Streams (Node.js documentation)
- Web Streams (MDN documentation)