Giter VIP home page Giter VIP logo

next-tailwind-typescript's Introduction

Next.js 14 & Tailwind & TypeScript

Tutorials

Auth

File upload

Server vs Client sides

  • CSR:
    • What is it:
      • Server gives <div id="root"></div> and JS to client. Client renders it all
    • Disadvantages:
      • Bad SEO
      • Browser must render all the JS on browser first before website us usable
  • SSR & Hydration:
    • What is it:
      • Rendered on server then send to client. Hydration takes over and makes interactive.
    • Types:
      • SSR: Rendered on server at request time. Good for personalized contents, eg: logged in users
      • SSG: Rendered on server at deploy/build time. Good for largely static contents, eg blogs
        • ISR: When data changes, individual pages gets rebuild, instead of the whole site.
      • More info on various rendering patterns: https://www.youtube.com/watch?v=Dkx5ydvtpCA
    • Disadvantages:
      • Server must get all the needed data before it renders the page
      • All JavaScript must download from the server before the client can be hydrated with it.
      • All hydration has to complete on the client before anything can be interacted with.
  • SSR & Suspense:
    • What is it:
      • The <Suspense component>, allowing:
        • HTML streaming: Server don't need all the data before it renders the page
        • Code splitting: JavaScript are streamed to the browser piece-meal
        • Selective hydration: Hydration in piece-meal, according to priority or need
    • Disadvantages:
      • If there a lot of JS, then browser still need to download them all eventually. There has to be a better way, ie: some of the JS work can be done on the server
      • Things that dont need hydration gets hydrated too
  • React Server Components:
    • What is it:
      • React invented Server components in version ~18/19, Next uses it since version 13. Next introduced App router in version 13, it's built around the RSC architecture. In App Router projects, a component is server side by default, unless have "use client" specified at the top of the file.
      • Server and Client components are seperated.
      • Server components only runs on the server, it never gets downloaded to the browser, hence reducing the load on the browser.
      • Client components handles interactivity
    • Advantages:
      • Less JS need to be download to browser
      • Data fetching in server components, on server side, which is closer to data source, hence faster.
      • Sensitive info kept on server side
    • More info:
  • Qwik Resumability: https://www.youtube.com/watch?v=t11M-Fj6iiQ

Next 13 changes

Next 13 added the new App Router on top of its pre existing Page Router

SSR, SSG & ISR

In App Router

fetch (URL), {
  cache: "force-cache", // SSG
  cache: "no-store", // SSR
  next: {revalidate: 1} // ISR
})

fetch vs Next's patched fetch:

In Page Router

  • SSR: getServerSideProps
  • SSG: getStaticProps & getStaticPaths
  • ISR:
function getStaticProps() {
  // ...
  return {
    props: { THE RESULT },
    revalidate: 1
  }
}

https://nextjs.org/docs/pages/building-your-application/configuring/typescript#static-generation-and-server-side-rendering

See also

Todo

next-tailwind-typescript's People

Contributors

b33fb0n3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.