akveo / nebular

:boom: Customizable Angular UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/nebular
MIT License
8.07k stars 1.51k forks source link

Angular 17 or higher with Server Side Rendering #3273

Open balu192 opened 1 week ago

balu192 commented 1 week ago

Issue type

I'm submitting a ...** (check one with "x")

Issue description

Current behavior & Steps to reproduce: I use the Nebular Auth modules in version 13. I tried to use the Nebular Auth Modules with a basic angular 17 application and I activated server side rendering for Angular 17, because Nebular is compatible with server side rendering.

After updating to SSR, I tried to use ng run sampleapp:prerender

I get following error: ERROR ReferenceError: localStorage is not defined at NbTokenLocalStorage2.get (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1668:351555) at NbTokenService2.publishStoredToken (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1668:352798) at new NbTokenService2 (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1668:352232) at NbTokenService.ɵfac [as factory] (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1668:352846) at R3Injector.hydrate (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1618:29688) at R3Injector.get (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1618:26934) at injectInjectorOnly (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1618:6459) at Object.ɵɵinject (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1618:6629) at NbAuthService.ɵfac [as factory] (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1668:355586) at R3Injector.hydrate (D:\SERVER\sampleapp\dist\sampleapp\server\vendor.js:1618:29688)

Some Nebular Classes and services uses the localStorage, but I didn't find a solution, sample or documentation at the wohole web for using Nebular with Standard SSR with a basic project of Angular 17or higher.

Expected behavior: The Nebular modules works directly with server side rendering or there is some documentation for using angular with ssr,because this will be the standard for all implmentations in the future versions of Angular. Please add some sample project and documentaton for the Angular SSR topic.

Other information:

npm, node, OS, Browser


Node v20.11.1
OS: Windows (10)
Browser: Chrome/Safari/Firefox

Angular, Nebular "dependencies": { "@angular/animations": "^17.3.0", "@angular/cdk": "17.3.0", "@angular/common": "^17.3.0", "@angular/compiler": "^17.3.0", "@angular/core": "^17.3.0", "@angular/forms": "^17.3.0", "@angular/platform-browser": "^17.3.0", "@angular/platform-browser-dynamic": "^17.3.0", "@angular/platform-server": "^17.3.0", "@angular/router": "^17.3.0", "@angular/ssr": "^17.3.11", "@nebular/auth": "^13.0.0", "@nebular/eva-icons": "^13.0.0", "@nebular/security": "^13.0.0", "@nebular/theme": "^13.0.0",