diff --git a/packages/server-renderer/__tests__/ssrTeleport.spec.ts b/packages/server-renderer/__tests__/ssrTeleport.spec.ts
index fda95918..f26c9035 100644
--- a/packages/server-renderer/__tests__/ssrTeleport.spec.ts
+++ b/packages/server-renderer/__tests__/ssrTeleport.spec.ts
@@ -117,4 +117,21 @@ describe('ssrRenderTeleport', () => {
'helloworld'
)
})
+
+ test('teleport inside async component', async () => {
+ const ctx: SSRContext = {}
+ const asyncComponent = {
+ template: 'content
',
+ async setup() {}
+ }
+ const html = await renderToString(
+ h({
+ template: '',
+ components: { asyncComponent }
+ }),
+ ctx
+ )
+ expect(html).toBe('')
+ expect(ctx.teleports!['#target']).toBe(`
content
`)
+ })
})
diff --git a/packages/server-renderer/src/renderToString.ts b/packages/server-renderer/src/renderToString.ts
index cf6e9759..f35ee9d6 100644
--- a/packages/server-renderer/src/renderToString.ts
+++ b/packages/server-renderer/src/renderToString.ts
@@ -63,9 +63,11 @@ export async function renderToString(
input.provide(ssrContextKey, context)
const buffer = await renderComponentVNode(vnode)
+ const result = await unrollBuffer(buffer as SSRBuffer)
+
await resolveTeleports(context)
- return unrollBuffer(buffer as SSRBuffer)
+ return result
}
async function resolveTeleports(context: SSRContext) {