fix: enable SSR support for Vaul without using Portal#598
Open
m-anikanov wants to merge 1 commit intoemilkowalski:mainfrom
Open
fix: enable SSR support for Vaul without using Portal#598m-anikanov wants to merge 1 commit intoemilkowalski:mainfrom
m-anikanov wants to merge 1 commit intoemilkowalski:mainfrom
Conversation
When attempting to use Vaul in SSR (Server-Side Rendering) mode without Portal, the application throws an error due to direct access to the document object, which is not available in a server environment. This commit addresses that issue by ensuring that any DOM-specific logic (such as referencing document.body or manipulating the DOM) is gated behind a client-only check. This allows Vaul to render content directly into the DOM during SSR, which is critical for SEO purposes—ensuring that the initial HTML contains the modal content for proper indexing by search engines. This fix makes it possible to safely render Vaul modals server-side without relying on a Portal, improving compatibility with SSR frameworks and better supporting SEO-sensitive use cases.
gstcarv
approved these changes
Sep 8, 2025
|
any chance of merging this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When attempting to use Vaul in SSR (Server-Side Rendering) mode without Portal, the application throws an error due to direct access to the document object, which is not available in a server environment.
This commit addresses that issue by ensuring that document is defined. This allows Vaul to render content directly into the DOM during SSR, which is critical for SEO purposes.
This fix makes it possible to safely render Vaul modals server-side without relying on a Portal, improving compatibility with SSR frameworks (like Next.js) and better supporting SEO-sensitive use cases.