package server-reason-react
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=b97fbe6a7c3e5e1a7775e0f6498f257acaaa7e272177a9a3e0e50b7a49408d7c
sha512=b27a94618c367c80efef83a41c2a59c9cc7848fd753049ed40fa1f2cface1ef34cf3a995835bf08e2eb59c3186911f429b4706ed07dcb9724df6af5eb012a31d
doc/universal-code.html
What does universal code mean
The goal of server-reason-react
is to enable running your client components in the server, but not only that, it also makes it easier to write code that can be shared between the server and the client. This is what we call universal code.
Challenges of universal code
One of the challenges of sharing code is that the server and the client platforms have different APIs available. You can't use browser's APIs on the server, such as document.querySelectorAll
and you can't use server related APIs on the client such as any filsystem operations.
In this aspect server-reason-react is not much different than Node.js. Node.js doesn't provide the global window/document objects and leaves the user to ensure the usages of those are handled manually.
In our case, we don't have any implementation for the browser APIs but we need the code to compile, so we provide a few utilities to make it easier to have code compiled.
Universal modules from server-reason-react
server-reason-react
comes with a few modules that are compatible with both server and client, to make it easier to write universal code and don't worry about the platform.
Belt
is an implementation ofBelt
that would work on both server and client.server-reason-react.belt
(Unstable)Js
is an half-implementation of theJs
module from melange.js, and many parts aren't implemented and some other parts aren't possible to implement on the server (Unstable, it raises "NOT IMPLEMENTED" for missing functions).server-reason-react.js
Webapi
is a shimmed version ofmelange-webapi
that works crash at runtime if you call those APIs on the server.server-reason-react.webapi