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 for Todo demo. #290

Closed
jafioti opened this issue Oct 26, 2021 · 2 comments
Closed

SSR for Todo demo. #290

jafioti opened this issue Oct 26, 2021 · 2 comments
Labels
question Further information is requested

Comments

@jafioti
Copy link

jafioti commented Oct 26, 2021

This is not exactly a bug, but there seems to be no clear answer on the Discord server, so I will ask here. I am using the sycamore-rocket-template project, and am trying to re-create the todo demo in it. Since it uses SSR, it complains that the Location object used for saving/loading todo lists is only available on wasm targets.

How can this be worked around? What is the recommended way of solving this, when doing SSR and using wasm-only functions? Is there a way to only use SSR for certain routes?

@jafioti jafioti added the C-bug Category: bug, something isn't working label Oct 26, 2021
@lukechu10 lukechu10 added question Further information is requested and removed C-bug Category: bug, something isn't working labels Oct 26, 2021
@lukechu10
Copy link
Member

Right now on the latest release (v0.6.3), the way to do this is a bit obscene:

if TypeId::of::<G>() == TypeId::of::<DomNode>() { ... }

What this does is basically check if the type of G (the rendering backend) is the browser DOM (DomNode), thereby executing the branch only when in the browser.

You can put your browser only code in there (such as accessing Location).

Once #274 is merged, this will be a bit clearer with:

if G::IS_BROWSER { ... }

Please feel free to reopen if this doesn't answer your question.

@jafioti
Copy link
Author

jafioti commented Oct 27, 2021

Ok awesome! I eagerly await that merge!

@jafioti jafioti closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants