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

feat(ssr): add SSR support #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat(ssr): add SSR support #28

wants to merge 1 commit into from

Conversation

wvffle
Copy link

@wvffle wvffle commented Feb 5, 2023

Closes #27

@hl037
Copy link
Owner

hl037 commented Feb 5, 2023

Hi, thanks for pointing it out !
Could you explain why it was not SSR friendly and how your changes that befaore I merge ?

@wvffle
Copy link
Author

wvffle commented Feb 5, 2023

Sure:

The first time that the <component> was assigned a value was within onMounted hook. When app is rendered during SSR, this hook does not fire, as no components are mounted, only static HTML is generated. Hence I've an initialValue constant that is passed to the body of the <component> or to the v-html depending on the noHtml prop. That way, when server is rendering the component, it already has the initialValue provided in the template, so it can render it.

Without these changes, the component is empty until hydration (which can take a short while)

@hl037
Copy link
Owner

hl037 commented Feb 12, 2023

Thanks for the explanation.
I was actually wondering if the v-if / v-else is really necessary ?

@wvffle
Copy link
Author

wvffle commented Feb 21, 2023

This is what bothers me as well. From my previous testing, whenever v-html is present, it is always chosen over the content inside the tag.

Maybe a <span> with v-html would also work? I don't have the time to test it now to be honest.

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.

Add SSR support
2 participants