Server side rendering

Can json forms be used with server side rendering?

[original thread by Stefan Čović]

In general yes (React). Some points to consider:

  • At the moment we still have a useLayoutEffect in there which will throw a warning but you should be fine ignoring it for now. In the next major release (2.5.0) we will probably get rid of it.

  • When your schema needs resolving you probably render a LoadingComponent so you might want to resolve already beforehand on the server.

  • When rendering Material UI you need to make sure it works properly as some elements render different depending on their environment as there is no browser available on the server.

[Stefan Čović]

Thank you

[Stefan Čović]

When i import jsonforms/react , i get this error Uncaught ReferenceError: process is not defined, and my functions stop working on client, without importing from jsonforms/react everything seems to work fine, any idea?
Also material-ui renderers wont render in browser, but vanilla renderers work

Hi @stefan-covic(stefan-covic), could you explain a bit more where and how this error occurs? Json Forms should work in any SSR rendering case.

Regarding Material UI I’m not surprised that they don’t render on the server side as Material UI’s reactive rendering expects certain media queries to be available. This is not the case by default in the server environment. We hit the same problem with our unit tests where we had to manually add a window mock for them to render. You’ll have to provide something similar. Note that this is not an issue with JSON Forms but a feature of the Materal UI.