-
Notifications
You must be signed in to change notification settings - Fork 41
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
Universal support #18
Comments
Hi @kadosh1000, what is the exact error you are getting with Angular Universal? |
Hello, same request here. At least please add some condition to prevent localstorage to be accessed on server rendering : ex
|
Hello @moioo91120, thanks for using |
Yes, thanks for your port of angular2-localstorage, it's very convenient. Actually, I use localstorage to store customer token. So I don't really need localstorage to render the page on server side. However, when I compile my project with angular universal, I get It would be perfect if we had the following behaviour, tell me what you think of it :
So basically ignoring the @localStorage for server rendering. |
Any news about this issue? @DanielKucal |
Somewhat confused by this issue. It's mentioned here the issue with running in non-browser instance is the references to window. But in the readme of this project, it is mentioned that it supports |
This is related issue: May be switch between BrowserStorage (will use browser storages) and ServerStorage (will use localstorage-polyfill) and using the interface form base class StorageService is good idea. What do you think? |
Tested today to see if this works with Universal. I created a new Angular project, ran the SSR installation as per docs.
|
@Gitelaus, it works with NativeScript when using https://github.com/NathanaelA/nativescript-localstorage, which polyfills storage functions in NS environment. I'd suggest all polyfilling your server environment, e.g. like presented here https://github.com/Angular-RU/angular-universal-starter/blob/master/server.ts#L11 |
Hi Guys, any update on this? |
Hi @DanielKucal I think that polyfill will work but only for localstorage and not for session, what do you think? have you tested it? |
I don't have an environment to test it at this moment. Why it would not work session storage? The goal of polyfills here is to just pretend that those globals exist, not actually work, it's just for rendering the template, right? |
Hi guys, that what I've used on server side just to get the app working: import 'localstorage-polyfill';
(global as any).sessionStorage = (global as any).localStorage;
(global as any).document = {cookie:''};
(global as any).window = {
location: {}
}; You need to insert this at your |
Hi guys I am trying to run npm run dev:ssr but getting I tried the polyhill as Ledzz suggested. No joy. I am using Angular 14 |
this doesnt work for me document is not defined |
Does this work with npm run dev:ssr for you? It doesnt work for me still document is not defined |
Can we try to implement this? |
I am getting error
when trying to npm run dev:ssr |
Hi,
It seems that the package does not support universal.
I am using universal for SEO, and it is part of angular since version 4.0.0
Are there any plans to support it?
The text was updated successfully, but these errors were encountered: