LinaYahya / nextJs-workshop

NextJs code along workshop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data fetching code along workshop

We’ve explained that Next.js has two forms of pre-rendering: Static Generation and Server-side Rendering.Now, we’ll talk in depths about data fetching strategies for each case.

We'll code the three unique Next.js functions you can use to fetch data for pre-rendering:

Now code time

We’d like to create a note App, to view our notes, add new note, and view specific note. We'll build our pages with nextJs two forms of pre-rendering, First with static generation then with serverSideProps, While we're working in the development mode we'll not notice the difference. So after all is done try to build your app, add new note, check notes at the home page, What can you notice?!

  1. Clone this repo
  2. check files
  3. pgcli then \i path of createDB.sql
  4. pgcli DB_URL from .env then \i path of build.sql
  5. cd todo && npm i
  6. npm run dev
  7. start from pages/index.js , You can notice that notes are static data try to fetch it by following comments,
  8. When you finished go to pages/[id] , also follow the comments.
Have fun time 😉 , Don't forget Documentation is your friend

About

NextJs code along workshop


Languages

Language:JavaScript 68.9%Language:CSS 27.1%Language:PLpgSQL 3.9%