-
Notifications
You must be signed in to change notification settings - Fork 11
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
Getting better at control of what runs on the server. #116
Comments
How to know you're in node:
|
In the documentation, we can show how to use this module to prevent code from running on the server: We might be able to create an example shim for some API to show users how to do it, then gather a collection of them from the community and link to them in the docs when we know about them. |
Dealing with SSR in a "polymorphic" fashion is indeed an art and you have Another big consideration is when doing ssr where the app mounts onto the https://github.com/iliakan/detect-node/blob/master/index.js — |
Here's a good one for localStorage on the server: |
@matthewp or @justinbmeyer Could we make
|
Sounds reasonable to me, by the way |
Moved this to donejs/done-serve#4 |
As was noted in this issue, it's not really simple to control what code runs on the server without setting up checks for attributes or methods that don't exist on the server as you run into them. So, how do we help each other become better SSR developers? SSR definitely seems to work fine with the majority of the code it encounters. Maybe I'm just unlucky and I'm running into this more often because I like to play with sockets. Really, the only two scenarios I've encountered so far are
window
that don't exist on the server, specificallylocalStorage
andsessionStorage
.Are there other issues that developers using SSR are running into besides these ones? A section in the docs on "Things to know when working with SSR" would be nice to have so that experienced devs can help the newcomers.
Maybe as a backup option for flow control we can inject global utility functions into the page that help control what runs on the server? Functions like
onClient()
that should evaluate tofalse
on the server andtrue
on the client, oronServer()
that would do the opposite. They could at least be useful for troubleshooting an app that won't load in SSR. The downside with these functions would be when you want to run your code in a location that doesn't support SSR, like as an iOS app. They'd have to be shimmed in or removed.I think ideally we would find each problem area and make it work great (no errors that stop rendering) without modifying our code. Based on what I saw with the
noop()
shim for socket.io on the server, I think we've already been trying to do this.What are some other ideas that would help people more easily use SSR?
The text was updated successfully, but these errors were encountered: