I was reading about Angular 2 Server side rendering with node.
But I cannot find an example or explain how should I do that. I need to render some pages with angular from server, any advice?
Well, look at this starter kit https://github.com/alexpods/angular2-universal-starter. It has server side rendering, web workers support (entire angular2 application is running in a web worker) , lazy loading (using webpack's code splitting) and many other things. I hope it will help you.
Disclosure: I'm its author.
This is the example the creators of angular-universal used in their talk, its a working repo -> https://github.com/angular/universal-starter/tree/angular-connect
And this is the talk - Full Stack Angular 2
Take a look here: https://universal.angular.io/
Looks like 'some' of the official documentation/site is now up. API docs are in the code but for quick reference see these links:
https://universal.angular.io/api/universal/index.html#typedoc-main-index https://universal.angular.io/api/preboot/globals.html
Nice third party overview and setup doc: https://mickaelkerjeanblog.wordpress.com/2016/05/02/angular-universal/
There's another example repo at https://github.com/ng-seed/universal showcasing both Universal and lean Angular on a single project.
This application uses platform-server
delivered with Angular 4.0.0, and it could be a good starter/seed project until Angular provides some documentation about the use of platform-server
.
Furthermore, it covers most of the features of angular2-webpack-starter by AngularClass such as async/lazy routes, SCSS compilation (both inline and external), dev/prod modes, AoT compilation via @ngtools/webpack
, tests, TsLint/Codelyzer, @types and maybe more.
Disclosure: I'm the author too :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With