Angular Vienna, Server Side Rendering and Pre Rendering with Angular Universal, July 2019

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ย. 2024
  • Talk by Ferdinand Malcher
    Single page applications in their pure form have one conceptual problem: the JavaScript code runs in one single "empty" HTML page. Search engines like the Google Bot don't like rendering JavaScript and see nothing but a blank page. SEO becomes almost impossible! What is more, before the user can interact with our app, the code must be downloaded and rendered. This extends loading time and makes users frustrated.

ความคิดเห็น • 58

  • @soniar4i
    @soniar4i 4 ปีที่แล้ว

    You last couple of minutes about lazy loading in server are gold, I, of course, forgot to add that. Thanks a lot :)

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว +1

      Please be aware that this is not necessary anymore with Angular 9 and Ivy 🙂

    • @chicagoboy279
      @chicagoboy279 4 ปีที่แล้ว

      @@ferdinandmalcher7434 how to apply ssr in angular 9?

    • @ferdinandmalcher
      @ferdinandmalcher 4 ปีที่แล้ว

      @@chicagoboy279 The same way I showed in the video. ng add and then use the provided NPM scripts.

    • @junaidamjad3510
      @junaidamjad3510 4 ปีที่แล้ว

      @@ferdinandmalcher how to apply it on a specific route in our application?

  • @SameeraSenarathna
    @SameeraSenarathna 3 ปีที่แล้ว

    Great Explanation on Angular Universal. Thanks for Sharing 💖

  • @junaidamjad3510
    @junaidamjad3510 4 ปีที่แล้ว +3

    can we do ssr on a specific route?

  • @mirnahaddad5227
    @mirnahaddad5227 3 ปีที่แล้ว +1

    need help, I am using angular 10, when I applied the angular universal SSR and pre-rendering, but I got window is not defined I tried all the ways by injecting it and use it globally , and by use isPlatformBrowser but nothing solve the problem , i need to know how i can know the root cause of the problem in order to know what's the solution for it , Thank you :)

  • @stevemurch3245
    @stevemurch3245 4 ปีที่แล้ว +1

    Really clear, beautifully explained.

  • @rogervanwile
    @rogervanwile 4 ปีที่แล้ว +1

    Great talk, helped me a lot! Thanks for sharing!

  • @dp5050
    @dp5050 4 ปีที่แล้ว +1

    Hi Ferdinand, Its a serious matter here! I've been working on SSR since 30+ days, and still stuck on somewhere.
    Actually I'm working on an angular project where all the DOM operations, localStorage, sessionStorage, cookeis etc. are widely used. But for SEO purpose and Social Platform sharing, I need to update meta tags dynamically, which is only possible by using SSR. So I've implemented this, I got a lot of errors and challenges but I've resolved all those one by one. Even for lazy loading with http calls server was not working fine, then I changed it by switching the platformbrowser. Now project is running with SSR and seems ok with existing functionalities. But what I saw, if I see view source of the page there's not all rendered html showing up inside ... .
    And also there, meta tags are not dynamically added as per page needed.
    I've figured out something, its making all http requests at platformbrowser, and not updating meta tags dynamically.
    Finally I'm lost and confused. So plz help me out step by step to achieve this SSR stuff.

  • @ubaidiftikhar1220
    @ubaidiftikhar1220 4 ปีที่แล้ว

    Hi,
    Did the prerendered with: ng run App:prerender
    and then Server that app for SSR with: node dist/app/server/main.js
    But not getting the statics routes as pre-rendered. Any help on this
    Thanks in Advance

  • @ShaikhShariq
    @ShaikhShariq 4 ปีที่แล้ว +2

    It was quite interesting talk and very useful. It was good I chose to go though this rather than boring documentation. If you might have covered or pointed out any resource on how we can differentiate between bot request and actual user request to redirect request to express server.

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว +1

      To difefrentiate between bot and actual user you need to analyze the user agent string from the request. You should use a useragent parser for this, of course, like this one: www.npmjs.com/package/useragent

    • @ShaikhShariq
      @ShaikhShariq 4 ปีที่แล้ว

      @@ferdinandmalcher7434 Thank you, just wanted to know that there is nothing fancy to be done after the server and client files generation. I need to setup my web server to redirect based on useragent string to node server or the actual server hosting client site.

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว

      @@ShaikhShariq Yep, there is no built-in mechanism to determine the user agent. The Node.js server is the only instance that can read the useragent from the request. If you want to pass this to the application (e.g. to not render some parts for a bot) you can provide that information via the "providers" array within the ngExpressEngine.

    • @ShaikhShariq
      @ShaikhShariq 4 ปีที่แล้ว

      @@ferdinandmalcher7434 I do have my main server as apache, which will host client site and additional node express server I will configure to host site for bots. Does this sound correct ?

  • @rodolfonogueira7254
    @rodolfonogueira7254 4 ปีที่แล้ว +2

    Brilhant talk!!

  • @kanyewest1503
    @kanyewest1503 4 ปีที่แล้ว +1

    My project on angular 8 compile successfully with npm run compile:server. But when i tried it run it with command node dist/server it shows me an error like "ReferenceError: window is not defined". Can anyone help me!

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว

      I did not mention this in the talk but: You can not use the "window" object in your code on the server because there is just a DOM emulation, no real DOM. You need to create a platform switch and ignore the code that uses window when the app runs on the server. You can use the functions "isPlatformBrowser()" and "isPlatformServer()" for this.

  • @hernanangular8124
    @hernanangular8124 3 ปีที่แล้ว

    Thanks you very much, good job!!

  • @horaciosoldman1569
    @horaciosoldman1569 5 ปีที่แล้ว +1

    Thank you Ferdinand :)

  • @creativa5140
    @creativa5140 5 ปีที่แล้ว +2

    prerender not load

  • @sangeethajothiprakash2295
    @sangeethajothiprakash2295 2 ปีที่แล้ว

    I am unable to compile it is not generating server.js file what to do sir

  • @Pranavk-tc5sc
    @Pranavk-tc5sc 5 หลายเดือนก่อน

    so I doubt this after 4 years😂. because now I gonna implement this. The thing is that if I use Django as the back end, is it mandatory to use the express engine?

  • @iFootballBR
    @iFootballBR 4 ปีที่แล้ว +2

    You save my life!

  • @Mr.Naguib
    @Mr.Naguib 5 ปีที่แล้ว +2

    I want to like that 100 times

  • @09sangram
    @09sangram 4 ปีที่แล้ว

    Great talk. Thank you for the tutorial

  • @nahidmorady3023
    @nahidmorady3023 4 ปีที่แล้ว

    thanks for sharing, It was very practical

  • @chandansingh9742
    @chandansingh9742 4 ปีที่แล้ว +1

    Hi Ferdinand, this is very helpful, thanks. quick question, how can we trigger the node backend rendering from a Java/spring based platform. Any link you can share?

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว

      In fact I never did this before... here's two links that might help:
      github.com/angular/universal/issues/280
      github.com/swaechter/angularj-universal

  • @FMAlmeidaLeite
    @FMAlmeidaLeite 2 ปีที่แล้ว

    Me ajudou muito! Obrigado!

  • @khalid19ist
    @khalid19ist 4 ปีที่แล้ว +2

    please how to deploy angular universal in IIS ...its bit confusing ....every only making tutorial on development mode..no one show after deployment ..please sir ....

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว

      The deployment works the exact same way as without pre-rendering. After running the pre-renderer, your "dist" folder will contain all the files, HTML and JS. You can deploy this folder as is.

  • @ankithas1868
    @ankithas1868 4 ปีที่แล้ว

    Superb talk

  • @adeebspace7460
    @adeebspace7460 2 ปีที่แล้ว

    Hi Ferdinand, Good explanation. I was trying to implement CSR and SSR in my application. But i was not clear how to move forward. Could you please provide any sample code where few components as client side rendering and few components as server side rendering. (Tried Hybrid approach but i was not clear about it).
    It would be the great help. Thanks in Advance

  • @user-gp2xv5sx8k
    @user-gp2xv5sx8k 5 ปีที่แล้ว

    Hello! I tried to add prerender technic into my Angular 8 Universal application (29:07 timeline in the video), but I caught an error. Can anybody help me?
    node dist/prerender
    ERROR TypeError: Cannot read property 'load' of undefined

  • @shireeshkumar5319
    @shireeshkumar5319 5 ปีที่แล้ว +6

    crazy talk. was expecting lot of claps. :D

    • @ankithas1868
      @ankithas1868 4 ปีที่แล้ว

      Definitely crazy talk

  • @offir711
    @offir711 3 ปีที่แล้ว

    Wouldn't it be just faster and easier to use wordpress instead?

  • @abolfazlvayani784
    @abolfazlvayani784 4 ปีที่แล้ว

    Hello and Thank you.. that was so great. But I'm getting "Unable to extract routes from application". and I'm using lazy loading for my routes. Also I'm using angular 9 and ivy. I added ang../univ.. but when I type "ng run [project_name]:prerender" I get this error!. I would be thankful if anyone could help me.

  • @venkateshg3236
    @venkateshg3236 4 ปีที่แล้ว

    Can we use this in ionic Project

  • @lordmidi9202
    @lordmidi9202 4 ปีที่แล้ว

    good overview

  • @creativa5140
    @creativa5140 5 ปีที่แล้ว +1

    before of this run ng serve?

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว

      You don't need to run ng serve with Server-Side Rendering. You first need to build the client app (ng build) and the server app. The Node.js server then serves both the client and server app. Meanwhile there is also a dev server (like ng serve) for SSR. Use the generated NPM script "npm run dev:ssr" for this.

  • @hos7012
    @hos7012 2 ปีที่แล้ว

    clear but still nextjs is more easier

  • @LettuceBunnies
    @LettuceBunnies 4 ปีที่แล้ว

    👍🏻👍🏻👍🏻👍🏻👍🏻👍🏻💖💖💖💖💖💖

  • @manikantareddyp1594
    @manikantareddyp1594 4 ปีที่แล้ว

    where can I get github repo ???

  • @klemonso
    @klemonso 4 ปีที่แล้ว

    where is prerender.ts file !

    • @ferdinandmalcher7434
      @ferdinandmalcher7434 4 ปีที่แล้ว

      It was in the repo. However, as for Angular 9 the pre-rendering is integrated into the Angular CLI. You just need to provide a list of routes and the CLI will take care of the rest.

  • @hobbyturystaSEO
    @hobbyturystaSEO 4 ปีที่แล้ว

    i ve been there too