Server-side Rendering React from Scratch! (Server-side Rendering with JavaScript Frameworks)

Поделиться
HTML-код
  • Опубликовано: 25 авг 2024

Комментарии • 113

  • @pakpoomtivarkornkit8525
    @pakpoomtivarkornkit8525 6 лет назад +61

    server side rendering code start at 11:33

  • @FabianVilersBe
    @FabianVilersBe 6 лет назад +8

    You should use npx to execute binaries from the .bin folder. Npx will help the node runtime to select the right binary for you. Moreover, the syntax of your scripts will be much cleaner.

  • @HoomanAskari
    @HoomanAskari 6 лет назад +40

    Finally, the react episode. Thanks. But what about routing and flux/redux state?

    • @alexanderprisazhny2812
      @alexanderprisazhny2812 5 лет назад

      The approach I've met is to import store in server and pass its contents through a global variable (e.g. window.INITIAL_STATE=${store}) in index.html you pass to a client.

    • @jantomotulo3754
      @jantomotulo3754 3 года назад

      Hi, im currently looking for this too, if you dont mind if there any example for this please reply this comment with the source for the example. Thank you

  • @finncrisp9900
    @finncrisp9900 6 лет назад

    Nice! Javascript has really come a long way. Nice to see that the language is maturing and by combining it to the awesome tools like React and Firebase development becomes just a breeze and a pure joy. Keep it up guys!

  • @1414tyty
    @1414tyty 6 лет назад +5

    Beautiful React SSR Tutorial

  • @cauebahia
    @cauebahia 4 года назад +3

    Thanks for this tutorial. BTW, a tutorial on how to bundle cloud functions files using Webpack would be great!

  • @JFkingW
    @JFkingW 5 лет назад +14

    Is that basically what next.js does automatically for me?

  • @greatnile
    @greatnile 6 лет назад +25

    Nice tutorial, one note though,
    locally installed binaries are available for all scripts in your package.json without prefixing it with node_modules/.bin/binary-name
    so in webpack script you could've written webpack directly.

    • @vcamargo1000
      @vcamargo1000 6 лет назад +5

      Also, if you were in the project directory you could invoke the node_modules binaries from the terminal with npx, like npx webpack. I believe npx is available from Node 8.

    • @greatnile
      @greatnile 6 лет назад

      Vinícius Camargo that's cool!

    • @gligoran
      @gligoran 6 лет назад +1

      npx is bundled with npm from npm@5.2.0, but you can install it to just like any npm package even on previous version of npm.

  • @cplkickass
    @cplkickass 4 года назад +2

    If you guys could share a repo of the finished product of these examples that would be so helpful ... makes it way easier to track down why something isn't working when you though you followed along perfectly!!!

  • @dongronki
    @dongronki 5 лет назад +2

    if you use babel 7 (current ver), you need to change different dependencies in "package.json"
    "devDependencies": {
    "@babel/core": "^7.3.4",
    "@babel/preset-env": "^7.3.4",
    "@babel/preset-react": "^7.0.0",
    "babel-cli": "^6.26.0",
    "babel-eslint": "^10.0.1",
    "babel-loader": "^8.0.5",
    "babel-polyfill": "^6.26.0",
    "eslint": "^5.14.1",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "express": "^4.16.4",
    "firebase-admin": "^7.0.0",
    "firebase-functions": "^2.2.0",
    "firebase-tools": "^6.4.0",
    "webpack": "^4.29.5",
    "webpack-cli": "^3.2.3"
    }
    and ".babelrc" file
    {
    "presets": [
    "@babel/preset-env", "@babel/preset-react"
    ]
    }

  • @gemsy.net.reviews
    @gemsy.net.reviews Год назад

    Hi, i came a cross this video since im searching for dynamic tags for my web app.hope this is a good step and gonna now to searching how to combine all these benific things with my project .Thank you very mutch

  • @silviumarinescu2796
    @silviumarinescu2796 6 лет назад +11

    how did you put index.html in the functions folder ? as far as i know you can not access it in the public folder from functions

    • @bharatsahu184
      @bharatsahu184 4 года назад

      got any solution for this?

    • @anantrungta7984
      @anantrungta7984 4 года назад

      Same Error-
      Error: Error occurred while parsing your function triggers.
      Error: ENOENT: no such file or directory, open 'E:\thisisme\SSR\functions/index.html'

    • @bharatsahu184
      @bharatsahu184 4 года назад

      @@anantrungta7984 have you tried nextjs? it's easier than customising react for SSR.

  • @narisongandy
    @narisongandy 6 лет назад +5

    I created a github repository to implement the source code for the Firebase tutorials. The source code for this video is here: github.com/littlewhiteball/FirebaseTutorial/tree/master/Server-sideRenderingReact
    Welcome to add more source code for other videos to the repository! Let's share and make it easier for others :)

  • @alexanderhemming6148
    @alexanderhemming6148 4 года назад +2

    The webpack parts are entierly depricated

  • @MrKausti
    @MrKausti 6 лет назад +1

    You guys should really put the code in your videos to git. I love these and need these but being a beginner I have to watch multiple times. Would really help to have the final code to look at. Cheers.

  • @behnammohammadi5820
    @behnammohammadi5820 6 лет назад +8

    how transpile css file when use import './App.css'; in server rendering

  • @kikevanegazz325
    @kikevanegazz325 Год назад

    Excellent tutorial!

  • @pm_calabrese
    @pm_calabrese 6 лет назад +2

    Would be interesting to see preact SSR

  • @AndresVillanuevand
    @AndresVillanuevand 6 лет назад

    Awesome guys.. Really helpful!

  • @andrevenancio
    @andrevenancio 5 лет назад +2

    Been following this tutorial from the beginning. "firebase serve --only functions,hosting" command runs, but I dont see a SSR version. I see what I have on the public folder. Either something on the firebase api changed, or you're missing something...?

    • @ReedRizzo
      @ReedRizzo 4 года назад +1

      I had the same issue. Remove the index.html file from your public folder. It's taking preference over your cloud function. At least that was my issue.

  • @clearwavepro100
    @clearwavepro100 6 лет назад

    Awesome thanks for sharing this!

  • @anantrungta7984
    @anantrungta7984 4 года назад +1

    Getting this error -Error: Error occurred while parsing your function triggers.
    Error: ENOENT: no such file or directory, open 'E:\thisisme\SSR\functions/index.html'
    After firebase deploy- coz there is no index.html file in functions folder. HELP!

  • @alexanderhemming6148
    @alexanderhemming6148 4 года назад +1

    16:24
    change the second node_modules//bim/babel ro just babel. It will not currently work otherwise.

  • @matinsasan
    @matinsasan 5 лет назад +1

    Hey David East, I found your doppelganger on youtube, another youtuber with a German channel named Die Frage, and he's German. I sent him a comment to make a video about meeting you in US (or you him in Germany, who knows). I hope he reads my comment there and takes interest. I hope you take interest too. Might be awesome.

  • @pliavi
    @pliavi 5 лет назад +1

    Oh well, it's look like a big gambiarra :v
    And i didnt' understand the need of the ./functions folder and why create it "manually", it can't be done with webpack? and webpack didn't transpiled the file to use commonjs require?

  • @davidfu8174
    @davidfu8174 6 лет назад +2

    Can you make a new one with create-react-app?

  • @larsfroelich
    @larsfroelich 11 месяцев назад

    How do you exclude specific components from being rendered on the server-side?

  • @sulenchy
    @sulenchy 6 лет назад

    what advice would you give a beginner developer on server side rendering ?

  • @myaccount09011975
    @myaccount09011975 6 лет назад

    Really like the video. Could you please share the themes you had used ?

  • @soultouchingsongs
    @soultouchingsongs 6 лет назад

    Thank you so much.... 👍

  • @harshitpant3067
    @harshitpant3067 6 лет назад +8

    no need of including node_modules/.bin in npm scripts. npm do that for you.

  • @heratpatel7174
    @heratpatel7174 6 лет назад +1

    How to use ssr for specific component in React ?

  • @mycloudvip
    @mycloudvip 6 лет назад +1

    HI, great Video... I always struggle fetching json data, selecting objects and injecting those values into html and now that I am getting started with react-native it seems a bit more complex. Can you suggest a website or webtool where I can experiment with different fetching tools to request API data, so that I can become more familiar and experienced handling json files and API requests? Thanks

  • @MichaelSalo
    @MichaelSalo 2 года назад

    I followed most of this, except why a separate copy of all the component scripts? Can't the client and server use the same build files. They both have to transpile anyway.

  • @Webeli
    @Webeli 6 лет назад

    Awesome!

  • @tininottiny8685
    @tininottiny8685 2 года назад

    What font are you using on vs code, so legible😁

  • @juanyang838
    @juanyang838 4 года назад

    Are there any difference between isomorphic-fetch and normal fetch? Seems like an usage and a syntax are same

  • @kephas-media
    @kephas-media 6 лет назад

    Thank you!!!!!!!!!!!!

  • @oguzgurkanbilir1368
    @oguzgurkanbilir1368 2 года назад

    You better start from the invention of the alphabet!

  • @ishanmahajan7264
    @ishanmahajan7264 6 лет назад

    Can you make a similar tut for angular as well I'm hitting my head against wall since past few weeks but no success. I tried tapping keyboard as well though.

  • @jibin2706
    @jibin2706 5 лет назад

    Dont you have to authenticate before fetching the data from firebase?

  • @alexnezhynsky9707
    @alexnezhynsky9707 6 лет назад

    7:54 Could also match for an optional "x" character in your regex, so you only have one test, e.g. /\.js[x]?$/

    • @LuisCassih
      @LuisCassih 5 лет назад

      the optional [] is not necessary neither, the ? applies to 1-0 ocurrences, so using /\.jsx?$/ is valid too

  • @greatramu86
    @greatramu86 6 лет назад +1

    @13:25 - what happens if a new "fact" is created in database and user opens the URL? Will the server cache still be active and show the old data only? How can I invalidate server cache?

    • @ValAllenSamonte
      @ValAllenSamonte 6 лет назад

      Yeah I think it will serve the old data for a certain period, however the client js will probably be executed at some time and will replace the server side rendered html with the actual react app on the browser (of course with the updated data).

    • @greatramu86
      @greatramu86 6 лет назад

      that is what I thought too.. however if we plan to use this for say "public profile" page, it will not be nice to ask user to wait 10 min to see his/her changes. I can reduce the cache duration, but it will kill the purpose and end up using too much resources. Does anyone know what could be the best solution here?

    • @ValAllenSamonte
      @ValAllenSamonte 6 лет назад

      I mean, once the javascript on the client is executed, it will replace the server rendered old data with the new data. JS execution on the client will mostly take less than 5 secs to render, so users will just have a glimpse of the old data and will be immediately replaced by the new data. At this point, the caching is probably not an issue.

  • @devmrin
    @devmrin 6 лет назад +1

    at 5:03, how do you get your arrow function to look like ⇒ in vs code

    • @davidpotgieter4943
      @davidpotgieter4943 6 лет назад +1

      ⇒ github.com/tonsky/FiraCode/wiki/VS-Code-Instructions 🙌

    • @JohnArcher888
      @JohnArcher888 6 лет назад

      Mrinmay Mukherjee google "vscode ligatures"

  • @stianmaurstad
    @stianmaurstad 6 лет назад +1

    Ok, I am a newbie, but shouldn´t you explain why we would need this?
    Understanding why & with some quick history or background would help, rather then just deep diving.
    Great video though.. Thanks!

    • @mjabadilla
      @mjabadilla 6 лет назад

      ruclips.net/video/GQzn7XRdzxY/видео.html

    • @tugceakn9742
      @tugceakn9742 6 лет назад +1

      The most important reason is usually SEO. Search engines besides Google have problems rendering SPAs.

    • @clublati
      @clublati 6 лет назад

      This is just a useful tutorial on deploying to Firebase - if you use that. And I believe the main reason for SSR is performance.

    • @gabrielmedeiros9806
      @gabrielmedeiros9806 2 года назад

      I agree with you! People forget to explain why

  • @thelotus-zv9qz
    @thelotus-zv9qz 5 лет назад

    Please make a video Server-Side Rendering Vue

  • @troooooper100
    @troooooper100 3 года назад

    how do i get my vscode to look like this

  • @Andy-si1pl
    @Andy-si1pl 2 года назад

    IS this still relevant or is everyone using Next (which I a trying to avoid)

  • @n37-d
    @n37-d 5 лет назад

    hey, what font are you using?

  • @anujsinghanujucan
    @anujsinghanujucan 5 лет назад

    ⚠ ReferenceError: self is not defined, gives error when i run `node_modules/.bin/firebase serve --only functions,hosting`

  • @codewithsub5083
    @codewithsub5083 5 лет назад

    How to ssr for multipage app?

  • @fahad.hossain
    @fahad.hossain 3 года назад

    please make a new video on this.

  • @juanyang838
    @juanyang838 4 года назад

    is this tutorial outdated? most of packages get deprecated warns and won't run

  • @riskingeuphoria
    @riskingeuphoria 4 года назад

    That stuff at the start pre 11 min. is that basically what "create react app" does?

    • @shamim083
      @shamim083 3 года назад

      just creates a react app. Install the node js and run the command to create a new react app.

    • @kawerewagaba597
      @kawerewagaba597 3 года назад

      pretty much

  • @MehranTaherimoud
    @MehranTaherimoud 4 года назад

    Anyone knows the link to the source code repository of this project?

  • @behnammohammadi5820
    @behnammohammadi5820 6 лет назад

    nice

  • @AmitErandole
    @AmitErandole 6 лет назад +1

    Where is the link to the github repo?

    • @danielr.4511
      @danielr.4511 6 лет назад

      github.com/davideast/react-ssr-firebase-hosting

  • @sharps8726
    @sharps8726 4 года назад

    11.03 is that a webkit you are running on your Local Host?

  • @shubhendraraj114
    @shubhendraraj114 6 лет назад

    hey, if the public folder doesn't contain index.html , I am unable to deploy the on firebase. Firebase is giving internal server error. But if I add index.html in public folder, than SSR not working. Firebase is serving from bundle.js. I am unable to see dom element in view source. Can anyone help me ?

    • @sabashavidze4990
      @sabashavidze4990 Год назад

      you can get this file path.resolve(__dirname, "..") + "/public/index.html" by getting the sibling folder first and then index.html

  • @BearkFearGamer
    @BearkFearGamer 5 лет назад +1

    Nice but, im using create-react-app

  • @drantunes
    @drantunes 6 лет назад +1

    SSR vs PWA? Is possible to use SSR with PWA?

    • @cyrftube
      @cyrftube 6 лет назад +2

      You can use them together. SSR is just responsible for the HTML response to the initial page request. PWA is supported by fetching a Javascript file in a separate request. Once the JS for PWA is installed locally, you can avoid making the page request.

  • @96shahab
    @96shahab 6 лет назад

    What font are you using in this video?

    • @b0mav1
      @b0mav1 6 лет назад

      Fira Code

  • @torbenlarsen4396
    @torbenlarsen4396 6 лет назад +2

    Source code?

    • @narisongandy
      @narisongandy 6 лет назад +1

      You can check the github repository I created for the Firebase videos:
      github.com/littlewhiteball/FirebaseTutorial/tree/master/Server-sideRenderingReact

    • @aoijeka
      @aoijeka 6 лет назад

      thanks!

  • @brunomello7499
    @brunomello7499 2 года назад

    yeah, rendering to string is a terrible idea if you have a big chunk of content on your dom. Ideally you should render to a node streaml so that you can split your html into small chunks and have them quickly sent out to the client in order to reduce the time to first byte

  • @DanielRLuke
    @DanielRLuke 2 года назад

    The explanations are, to me. not clear. How is it that React not already rendered by a server? When you go to a URL, aren't you requesting info from a server? As usual, the tech person trying to explain what something is overlooks this extremely obvious point of confusion.

  • @user-vc2jn4td2e
    @user-vc2jn4td2e Год назад

    19:34

  • @aichpvee
    @aichpvee 6 лет назад

    "Webpack is RUN on Node." Are there any programmers other than me who can get this right? You'd think people who spend their entire lives working with grammars and syntax would be able to use grammar or syntax...

  • @vipulhirani831
    @vipulhirani831 6 лет назад

    Provide git repo for beginner.

    • @carlbowen
      @carlbowen 5 лет назад +1

      github.com/davideast/react-ssr-firebase-hosting

  • @shamim083
    @shamim083 3 года назад

    In a real app, we never pass props to the App component!. Looks like it serving a static html page.

  • @AlmazovS
    @AlmazovS 5 лет назад

    Too quick. It's very difficult to understand.

  • @mmsrp
    @mmsrp 5 лет назад

    next.js + firebase hosting really sucks

  • @lutfucan90
    @lutfucan90 6 лет назад +4

    VUE PLEASE QQ

  • @aditisharma2552
    @aditisharma2552 3 года назад

    very outdated. a lot of things have changed now.