Nebular: Server side rendering

Created on 8 May 2018  路  8Comments  路  Source: akveo/nebular

This is a feature request
Currently nebular does not support server side rendering
I followed this guideline:
https://github.com/angular/angular-cli/wiki/stories-universal-rendering
At the end I found out that nebular uses things which are not supported while rendering on the server side.
e.g. window, document, localstorage etc
Kindly fix this issue.

Most helpful comment

There is also problem running in SSR because of window is not defined in intersection observer module

All 8 comments

You might want to look into a work around discussed here - https://github.com/angular/universal/issues/830.

I have Nebular UI running in SSR setup with domino. There are other minor issues associate with it, but nothing that stops the application from running. See my server.ts here - https://github.com/akveo/nebular/issues/402 . Hope it helps.

I just successfully ran my application using domino
Thanks a bunch !

"So how did you use domino to resolve this? I'm just not getting this to work after upgrading to rc.10. It's specifically complaining about the theme module."

Hi @tdespenza, you can open a new issue with the details of the issues you are having.

"@nnixaa I got it figured out.

I just used jsdom-global instead of domino."

Any fix available? the problem is still present with ssr.

I found a solution for this. It is working for me, the nebular components just needs some modifications so it executes window.localStorage.getItem() only only if platform is browser.

Anyways here are the instructions.

  1. Move source to Angular Universal
  2. Follow @AnthonyNahas instructions in https://github.com/SebastianM/angular-google-maps/issues/1052 for each plugin thats complaining about "Unexpected import".
  3. Use Domino if you need to. Normally is not suppose to be used because Node does not have window. Instead you are suppose to check if the platform is browser and then invoke localstorage in that if statement. See this link for more information

Note: After been trying to get his working for several hours. I learned that Angular Docs is missing several things for SSR thats why i chose to move source to Angular Universal Starter instead.

There is also problem running in SSR because of window is not defined in intersection observer module

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mobarokhossain picture mobarokhossain  路  4Comments

mmezian picture mmezian  路  3Comments

rhajizadeh picture rhajizadeh  路  3Comments

muysewinkel picture muysewinkel  路  4Comments

andredatsch picture andredatsch  路  3Comments