React Server Side Rendering Introduction For Beginners - ReactJS ssr with Expressjs

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 2024
  • 📘New Course: Build full-stack React Typescript applications tsreact.maksim...
    Learn how to setup basic server side rendering using ReactJS and Express.
    Follow me on Odysee: odysee.com/$/i...
    React SSR (Server Side Rendering) is a technique when you pre-render initial state of your application on backend.
    It can greatly improve user experience if used correctly.
    🐦 Twitter: / ivanov_dev
    I write about React and TypeScript there
    Code for the tutorial: github.com/sat...

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

  • @HarshSingh-hk8fe
    @HarshSingh-hk8fe 2 ปีที่แล้ว +16

    this is the most straightforward to the point tutorial i've ever seen just amazing bro

  • @gooddha
    @gooddha 4 ปีที่แล้ว +11

    Хорошее видео, четко и по делу без лишней воды, шуток-прибауток и мычания!

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

      exactly

    • @user-yd7db3wd7w
      @user-yd7db3wd7w 3 ปีที่แล้ว

      @Snake ETH лично я дохуя чего не понял, но я ни разу не лез в бек, поэтому хз в ком проблема

  • @joantonio6331
    @joantonio6331 4 ปีที่แล้ว +7

    For those who would wonder how to update the website after you edited the app, simple rebuild it then re run ssr

  • @010timeboy27
    @010timeboy27 ปีที่แล้ว +1

    Still works. Preparing for interviews, and am looking for easy ways to implement SSR, other than NextJS.
    Side for everyone else. Your Index.js on the client-side will look slightly different to the video now:
    import { hydrateRoot } from "react-dom/client";
    const domNode = document.getElementById("root");
    hydrateRoot(
    domNode,



    );
    Happy coding

  • @atg1203
    @atg1203 4 ปีที่แล้ว +10

    Great video! You simplified it a lot compared to some of the other articles/videos I watched for React SSR.

  • @obednuertey6162
    @obednuertey6162 ปีที่แล้ว

    Gone are the days we have to use two different servers for the same application. This is so so super simple. I usually don't subscribe after I watch a video. But your channel man, definitely is one any developer has to subscribe to

  • @mohamethseck
    @mohamethseck 3 ปีที่แล้ว +5

    This video is perfect! Very simple and straight to the point.

  • @nuyi9411
    @nuyi9411 4 ปีที่แล้ว +10

    Simple code! Love it. Could you make a tutorial how to use it along with React-Helmet? Thanks!

  • @yt-sh
    @yt-sh หลายเดือนก่อน

    This helped understand SSR better, thank you

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

    I think I just learned THE DIM MAK on this page... thank you so much, you are LORD!

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

    Просто великолепно, начал сейчас учить реакт в связке MERN и мне очень важен SSR для СЕО, а тут все так понятно, спасибо за качественный контент)

    • @user-ov5tt6sc2f
      @user-ov5tt6sc2f 2 ปีที่แล้ว

      А этот метод Вам помог? Для меня тоже очень важен ceo, а писать приложения на next js не особо хочется

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

      @@user-ov5tt6sc2f Добрый вечер! Этот метод в итоге не пробовал, решил использовать Next.js, всё таки это более распространенное решение, много примеров как и что правильно делать

    • @user-ov5tt6sc2f
      @user-ov5tt6sc2f 2 ปีที่แล้ว

      @@sanyokes Спасибо за ответ!

  • @obednuertey6162
    @obednuertey6162 ปีที่แล้ว

    I am short of words man. It feels like dream come true.

  • @elite.topmotivation
    @elite.topmotivation 8 หลายเดือนก่อน

    I got this to work on the all new "bun.js" runtime, no need for babel but I had to do some modifications. Good Tutorial, thanks

  • @userfpdnbknsdbmfn
    @userfpdnbknsdbmfn 2 ปีที่แล้ว +1

    It works fine but i have a little problem. My dotenv-package isn‘t working anymore after implemented react-ssr, do have someone a Tip for me to fix it?

  • @densfloar
    @densfloar 3 ปีที่แล้ว +21

    Nice. It would be awesome and then I would subscribe if you took the time to explain why you do it this way. Maybe not every line, but for instance why replacing, why installing hydrate etc

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

    You are legend, thank you for explaining it in simple terms !

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

      Jan Horak thanks 😊

  • @alexon2010
    @alexon2010 4 ปีที่แล้ว +5

    Hello, friend I liked this approach for React SSR, it is very easy to understand, but I could normally use Redux, ReactRouter and Styled-Components, you would have a video that integrates these three points (Redux, ReactRouter and Styled-Components in React SSR)

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

      +1

    • @vitorfigueiredomarques2004
      @vitorfigueiredomarques2004 ปีที่แล้ว

      since ReactDom.hydrate simply makes the components from the client use the HTML generated from the server, it should integrate without any problem with other dependencies.

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

    I am using react router and getting error when I am trying to run in SSR mode

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

    This is great thank you. I see how this renders the HTML on server side. A question is why do we want to ignore styles?

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

      If you watch the whole video, you'll see that inside his server/index.js file at the first line he uses require('ignore-styles'); which is used just to ignore the style

    • @winnerleparadoxe6496
      @winnerleparadoxe6496 2 ปีที่แล้ว +1

      @@baraousseni1686 Yes but ignore the style?

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

    Thank you so much, bro, this video is very helpful for all, and your understanding way is ossom, thanks for sharing this, I request to one thing please can you make a video to CSR to SSR in vuejs, if you do please reply me, thanks a lot.

  • @igniousprogrammerip3536
    @igniousprogrammerip3536 ปีที่แล้ว

    Best video i just glad to know your channel

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

    Super! The best short explanation on youtube. Отлично! Побил даже учителей с Udemy.
    Немного суховато в конце. Было бы неплохо прогнать Клиентскую программу рядом с SSR и сравнить.

  • @Arthur-ql5vg
    @Arthur-ql5vg 3 ปีที่แล้ว

    Really straightforward explanations. Thanks a lot !

  • @prakharagrawal8983
    @prakharagrawal8983 ปีที่แล้ว

    Good and straight forward explaination

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

    thanks for all

  • @charlievered3899
    @charlievered3899 ปีที่แล้ว

    Thanks a lot for the explanation. I finally got it working!

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

    Loved the style, cheers mate!

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

    Ok, this just demystified ssr for me. Thank you!!

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

    по сути мы юзаем реакт как эдакий шаблонизатор. В случае с использованием React всё просто. Было бы круто увидеть сср с подключением Redux - там уже не всё так очевидно ))

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

      Да, можно watering редакс стора рассмотреть

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

    🤩

  • @arny699
    @arny699 5 หลายเดือนก่อน

    Thank you for this tutorial. Its great! How to add meta tags into the head of the pre-rendered html file, if we replace only root div?

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

    syntaxe: "node_modules" and not "node_module".

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

    amazing man... its interesting and you are the smart guy..

  • @ahmadkhan-xn2nk
    @ahmadkhan-xn2nk 2 ปีที่แล้ว

    sir showing error Warning: Expected server HTML to contain a matching in .

  • @sayandcode
    @sayandcode ปีที่แล้ว

    Damn! Rare content, and very well done too!

  • @Vasuchowdary
    @Vasuchowdary 2 ปีที่แล้ว +1

    you look like theon greyjoy from game of thrones any way nice explanation

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

    node_modules was misspelled in the ignore section.

  • @nitindaphale2008
    @nitindaphale2008 2 ปีที่แล้ว +1

    If Error "React undefined", then "Import React" in every component file specially if you are using React17+

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

      Thank you! 🙏

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

    Hoped you explained more. Helpful video nonetheless.

  • @kinekt2000
    @kinekt2000 3 ปีที่แล้ว +13

    какой классный тяжелый русский акцент, чувак ты ахуенен

  • @obednuertey6162
    @obednuertey6162 ปีที่แล้ว

    Man You are a Code God.😎. Thanks so so so much. But one more question. Do I need to build my create-react-app anytime I make changes to my Code?

  • @anl6777
    @anl6777 11 หลายเดือนก่อน

    You saved me! Thanks a lot

    • @satansdeer1
      @satansdeer1  11 หลายเดือนก่อน

      You're welcome!

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

    Great and clean tutorial. Thank you 🙏

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

    Thank you! This was very useful as a beginner.

  • @arturgorbunov3792
    @arturgorbunov3792 2 ปีที่แล้ว +1

    Can you please explain how to create SSR with Routes ? Especially with Router-V6 &&

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

    Straight to the topic.. 🥰🥰

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

    You are a genius. Thank you

  • @eforrenze
    @eforrenze ปีที่แล้ว

    tks for the sharing!

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

    How do you copy an entire line without selecting all the text?
    how do you select an entire line in a mac?
    how do you copy a line declaring a function and then only change the name of the function by deleting the entire word?
    all those shortcuts man, I'm new to macOS and I don't use VSCode as much, they'd be helpful

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

    Thank you! now I have an image how to use ReactDOMServer and ReactDOM.hydrate guy :D

  • @rahil-aliyev
    @rahil-aliyev 2 ปีที่แล้ว

    I think it does not work for me. Because I did everything, but when I clicked "view source page", it did not change

  • @bmsfx
    @bmsfx ปีที่แล้ว

    just crazy how much work is required to make this work, i have that you cant just take a already created page and say "this now react SSR" and then it works on your current code

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

    Dude, everything's great and appreciate you for the tutorial, but couple of things are bugging. First, can you make an example with the running react development server rather than build and second using this, it's giving me error that "require is not defined". please help me out with this.

  • @fitrianinasir5101
    @fitrianinasir5101 ปีที่แล้ว

    great tutorial but your bottom right corner video layer often covered up the code😥

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

    Very helpful, thanks Maksim!

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

    This was really straightforward and helpful. Thanks!

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

    I don't know how it will work for the content pages that we are fetching from APIs

  • @sharkdeng9253
    @sharkdeng9253 3 หลายเดือนก่อน

    good video. Can you have TypeScript version?

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

    You are cool!!!!
    Simple and clean code!!!!

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

    loved it , have one question though , I'll still need to host both sever and react app separate right ?

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

    Easiest SSR I've ever seen. I wonder if this is thanks to modern tooling; it seemed more difficult 3 years ago.

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

    Outstanding. Thank you.

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

    2022, the code in the repository doesn't work. The explanation is very good, unfortunately it doesn't work in you clone the repo and run it locally

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

    Very very good! I understand the purpose of the video, but I don't understand the hype around SSR these days. It seems like "back to the future". Did I misunderstand anything?

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

    did everything like in a video, "Reference Error: React is not defined", might versions are not matched or something missed ;)

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

    Hi, but this method don't render elements after fetched :(

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

      Hmm, could you please elaborate, what elements?

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

      @@satansdeer1
      Hello Maxim, i used axios in componentDidMount. I create table body with the data when bring the result, but unfortunately the created elements not rendering after fetching. I'm leaving the github link below
      github.com/Emgeomap/react_ssr

  • @48_subhambanerjee22
    @48_subhambanerjee22 11 หลายเดือนก่อน

    Nice

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

    thanks dude its working !

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

    your video is awesome, thanks a lot.

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

    Great vid - what plugin are you using on VScode to import/tab to get snippets? Thanks!

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

    Very helpful, thank you!

  • @akhlakpatel921
    @akhlakpatel921 ปีที่แล้ว

    That is working on local server, thanks for making it,
    but when we run npm run build, and then npm serve cmd to check dist folder is working or not, it giving me an error (Uncaught TypeError: n.createRoot(...).hydrate is not a function)
    please anyone help me

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

    1st of all, thanks so much dude! This is really well explained and written, you've got a new sub that will share this to anyone learning React!
    2nd, I have a few issues porting an older project to this. Could the reason be npm?

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

      MerceneX thanks, its hard to tell without seing the project, could you make an example repo with the reproduction of the issue you are having?

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

      @@satansdeer1 Wow, that was lightning fast. Thanks for the response man!
      /questions/61227711/problems-migrating-react-to-ssr-import-extends-from-babel-runtime-helpers-es
      I've posted the above question on stackoverflow already. The github repo link is in there as well. If you're interested in discussing this further? :)
      And really, thank you again.

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

      MerceneX I'll try to take a look later

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

      @@satansdeer1 Thank you

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

      @@mercenex6329 yo, i've checked your repo, I the scripts there don't seem to have `ssr` option. Am I looking in a wrong place, or is there something missing?

  • @ayushmishra9450
    @ayushmishra9450 4 หลายเดือนก่อน

    how to render react for differend routes in the same server ?

  • @user-zx4zv2bs3q
    @user-zx4zv2bs3q 3 ปีที่แล้ว

    Error: Cannot find module '/mnt/c/PROJECTS/right now/ssr-example/server/index.js'

  • @akich.1782
    @akich.1782 4 ปีที่แล้ว +1

    you look like the guy that kills John Wick's dog. joke aside this video is really helpful.

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

    we should use Server folder instead of build folder for deployment??
    Thanks for your efforts 👍

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

    Hi thanks for video but i have a issue like:
    ssr: `node server/index.js`
    problem with npm. There is likely additional logging output above.

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

    When m using Routers in my App.js after hitting localhost:8000 it's giving me an error Browser history needs a DOM

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

    Great video!

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

    Support for the experimental syntax 'classProperties' isn't currently enabled , getting this error

  • @gladimirjacobsen6356
    @gladimirjacobsen6356 ปีที่แล้ว

    I got an error React not found when running the app. Could you guys help me please?

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

    I was receiving an error when running `npm start` with this as hydrate could not match anything (the locally served files skip the express backend!).
    My fix has been to query the environment, i.e. if (process.env.NODE_ENV && process.env.NODE_ENV === 'production')
    Where true I am hydrating, where false I am rendering.
    To me this seems like a good way of keeping the benefits of the dev server (hot reload) whilst not impeding the built ssr behaviour, can you think of any drawbacks or alternatives?

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

    I’m wondering how to deploy this set app

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

    Good job man 😎

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

    63/5000
    It worked is that I have to run yarn build and then yarn ssr

  • @tenebrae1191
    @tenebrae1191 ปีที่แล้ว

    👏

  • @SangNguyen-gq7wq
    @SangNguyen-gq7wq 3 ปีที่แล้ว

    Error: Cannot find module 'app/theme'
    Require stack:
    - D:\F88Projects\WebPartner\src\App.js
    - D:\F88Projects\WebPartner\server\server.js
    - D:\F88Projects\WebPartner\server\index.js
    I get error when run ssr ??
    Please help me!

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

    what do you write on minute 9:11? Mine's not working and I don't know if it's because of that

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

    Kindly Make an other video that how can we use react helmet with ssr??

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

    import logo from './logo.svg'
    the above is not working. Image is not being loaded into the browser. Could you please help me with this?

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

      Simply delete both JSX tags mate along with the logo.svg file
      Then it should work (:

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

    @Maksim Ivanov How to put this code on production mode on hosting server because we are just putting build folder content on server how server/server.js read App component is this case?

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

      That's what I'm wondering too, did you find the solution?

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

      @@thatcoul we have to put all folders on to server. Like we setup on local as same we have to setup on other server like digital ocean node server etc.

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

      @@kalpittandon8999 Thanks

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

      @@thatcoul any time

  • @kolo1513
    @kolo1513 ปีที่แล้ว

    God bless You !
    If You would be so kind as to post some extended material using routing, that would be nice

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

    greate, but how should put it on cpanel host?

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

    Can you give an example with using an API to get the data and render that data server side?

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

      This's not working because i tried (Sorry if my english is bad)

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

    Hey dude, I don't get from where the build thing comes, can you explain? Like there is no build folder in the repo at all

  • @FullStackDevGreg
    @FullStackDevGreg ปีที่แล้ว

    LocalStorage WrongReferenceError error, how can I insert normal js function,

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

    window is undefined , how to solve this problem? pls tell me if anyone knows

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

    Maksim, how to resolve "ReferenceError: document is not defined" in this implementation ?

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

    Hi, I am getting an error saying React is not defined.
    How to solve this?