It seems like by default teleport
won't get rendered by using renderToString
.
Does any one know how to render and hydrate the teleport
component in Vue3?
I've found some tests here, but couldn't figure out how to apply this on a real world example, and couldn't find any information on this topic.
As far as I know, teleport in Vue 3 SSR needs special handling: https://vuejs.org/guide/scaling-up/ssr.html#teleports
You can check Evan's answer here:https://github.com/vuejs/core/issues/3869
To hydrate the teleport content, you need to use
teleports
property of the SSR context. Then, you need to inject them in the final html.console.log(context)
to see teleports object.This example may help to solve your problem:
App.vue:
server.js: