Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #173: Vue Body Teleport support #207

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

phlegx
Copy link

@phlegx phlegx commented Jun 12, 2023

#173: Like described in the official documentation of vue, we should consider to use an own DOM node for Vue body teleports:

Avoid targeting body when using Teleports and SSR together - usually, <body> will contain other server-rendered content which makes it impossible for Teleports to determine the correct starting location for hydration. Instead, prefer a dedicated container, e.g. <div id="teleported"></div> which contains only teleported content.

We have two possible solutions:

1. Teleport components are rendered only on client side (no hydration node mismatch).

<ClientOnly>
  <Teleport to="body">
    ...
  </Teleport>
</ClientOnly> 

But that eliminates a huge bonus from using SSR, as web crawlers (SEO) are not able to traverse JS. E.g. main menu as offcanvas side menu.

2. Required SSR rendering of body teleport components, by using a unique DOM node outside app node (solves hydration node mismatch).

<Teleport to="#body-teleports">
  ...
</Teleport>

with index.html like:

...
<body>
  <div id="app"></div>
  <div id="body-teleports"></div>
</body>

This is a solution for SSR body teleports only! Teleports inside root element (#app) should currently be wrapped as ClientOnly.

@phlegx phlegx mentioned this pull request Jun 12, 2023
Error TS2742: The inferred type of 'startServer' cannot be named without a reference to 'vite-ssr/node_modules/vite'. This is likely not portable. A type annotation is necessary.
@phlegx
Copy link
Author

phlegx commented Jun 13, 2023

@frandiox what do you think about this PR?

@phlegx
Copy link
Author

phlegx commented Jul 3, 2023

Hi @frandiox ! Can we merge this PR please?

@TimoStolz
Copy link

I have the same issue and would like to have this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants