renderToString() Render to HTML String
Last updated: 2026-10-22
renderToString() Render to HTML String
renderToString() renders an app to an HTML string on the server — the SSR output step, hydrated by createSSRApp on the client.
| Group | Render Functions & SSR |
|---|---|
| Kind | API |
| Scope | Global |
| Vue Version | 3.0+ |
| SSR Support | Yes |
📝 Syntax
import { renderToString } from "vue/server-renderer"
const html = await renderToString(app)
⚙️ Arguments
| app, context? | An app instance (optionally with an SSR context) |
|---|
Returns:Promise
▶ Example
Edit the code below and see the live result:
Output:
Shows the SSR notice (real rendering happens in Node).
💡 Key Points
ℹ️ Note Imported from vue/server-renderer — Node-only.
💡 Tip Pairs with onServerPrefetch and useSSRContext.
⚠️ Warning No window or document access under SSR.
🏷️ Related Render Functions & SSR
💡 Related Cases
More case studies coming soon.
📚 Related Tutorials
❓ FAQ
Q Usable in browsers?
A No — it is Node-only.
Q Relation to Nuxt?
A Nuxt wraps exactly this pipeline.
Q What does the output include?
A HTML plus serialised state for hydration.