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

SSR with renderTags() #29

Open
gxxcastillo opened this issue Feb 28, 2023 · 2 comments
Open

SSR with renderTags() #29

gxxcastillo opened this issue Feb 28, 2023 · 2 comments

Comments

@gxxcastillo
Copy link

gxxcastillo commented Feb 28, 2023

I'm using renderToStream() for SSR but renderTags() returns a string which ends up getting escaped. Is there a way to have something like renderTags() but have it return JSX?

@KevinBLT
Copy link

KevinBLT commented Jul 5, 2023

I need the same

@ryansolid
Copy link
Member

ryansolid commented Jul 25, 2023

The problem is how it gets inserted. Returning JSX doesn't really work for us because JSX doesn't really exist for us at runtime. So the way to insert it is either directly in the HTML string if you have it top level or, if inserting in Solid's JSX wrap it in an ssr call. It basically treats it like an already escaped template.

This is exported from solid-js/web. So you probably want to run this code in server only context (ie guarded by isServer or eqivalent). That being said the tags aren't there until the server finishes rendering so to make it work in the JSX you probably need to use something like useAssetsfromsolid-js/web` anyway. Which is why I didn't expect to see this issue as none of these APIs are documented so I figured most people would just be inserting their markup in an HTML string at the end where you wouldn't have to worry about escaping.

In any case I hope these hints help. SolidStart is also a good reference here.

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

No branches or pull requests

3 participants