How To Get Started With NextJS

How To Get Started With NextJS

Nextjs is a?Framework?for creating pre-rendered React websites by server-side rendering (SSR) or static side generation (SSG).

What is SSR ?

SSR is when react components are rendered into HTML pages on the server after the request comes from the user (browser).

What is SSG ?

SSG when the components are rendered into HTML pages at the build time.

What is the benefits of SSG and SSR in Nextjs?

The benefit of SSG and SSR is that they can improve a website’s performance. because components are already pre-rendered on the server which means less work in the browser, and also better SEO because the response of the server this time is HTML page and not blank page as the case with react application without nextjs.

Now let me create a nextjs project. And to do that we need to run the command : npx create-next-app nextjsdemo (nextjsdemo?is the name of the application, it can be whatever you want).

Aucun texte alternatif pour cette image
Aucun texte alternatif pour cette image

Now let us navigate to the directory that has been created by using?cd?command plus the directory name. Then to open the project in Visual Studio Code, we type in the terminal?code .?, and you can use whatever text editor you wish.

Aucun texte alternatif pour cette image

Files and Folders Inside Nextjs Project :

  • Node_modules folder?: here is where all our dependencies are stored.
  • Pages folder:?here where all our different page components will be created.
  • Index.js :?is the for the homepage.
  • _app.js file :?it is like a root component and all the pages components are rendered inside this root components.
  • API folder :?it is for API endpoints
  • Public folder :?it is where all of our public assets like images should be.
  • Styles folder :?it is for all the css files.
  • .gitignore file :?version control.
  • Package.json file :?it is to keep tracking the different dependencies.

Aucun texte alternatif pour cette image

The?“Scripts” object?in the package file just above, we have?“dev”:”next dev”.?It is used to run a local development server for us so we can preview the application in the browser. and to do that, in the terminal, we execute the command?npm run dev?and the application will start.

Aucun texte alternatif pour cette image

This component is rendered before it reaches the browser. During development, this is done through server-side-rendering which means the server renders the component then sends the HTML file to the browser. And that happens for each page requested from the browser. For example, when we type an URL, it will look for the component for that URL pre-render it and send it to the browser.

Any question, don't hesitate to post your question in comment here, or go to the website for much more about Nextjs and other technologies.

要查看或添加评论,请登录

Mohamed-Lamin Taleb的更多文章

  • Azure Networking(5) : Network security Groups

    Azure Networking(5) : Network security Groups

    We cannot talk about Azure network security group without mentioning Network security group, so in this article I will…

  • Azure Networking (4) : VPNGateway (Vnet-to-Vnet)

    Azure Networking (4) : VPNGateway (Vnet-to-Vnet)

    In this fourth articles about Azure networking, I would like to share with how to establish connection between two…

  • How To Build Your Own ChatGPT API With Express_js

    How To Build Your Own ChatGPT API With Express_js

    As AI is going so popular, I felt the need to explain how someone could build his own ChatGPT API using one of the…

  • Azure Networking(3) : Peering

    Azure Networking(3) : Peering

    Peering is the best way to open a connection between two virtual networks, so the virtual machines inside those virtual…

  • Azure Networking (2) : Private Endpoints

    Azure Networking (2) : Private Endpoints

    Private endpoints are somehow extremely Important when it comes to the privacy of the cloud and its security parameter,…

  • Azure Networking (1): Azure Private DNS Zones

    Azure Networking (1): Azure Private DNS Zones

    Azure private DNS zone is one of azure services to keep privacy on virtual networks (Vnet) in Azure networking, in this…

  • Patch Function in Power Apps : SharePoint Number Column

    Patch Function in Power Apps : SharePoint Number Column

    Patch Function in Power Apps : SharePoint Number Column Let me show you, how to update a column of the type Number in…

  • How To Call Power Automate From Canvas App

    How To Call Power Automate From Canvas App

    Here in this article, we’ll see how to call Power Automate From Canvas App using PowerApps(V2) Action in Power Automate…

  • How To Install WordPress: Step-by-Step Guide

    How To Install WordPress: Step-by-Step Guide

    Used by more than 455 million sites, WordPress is a content management system (CMS) that has existed since 2003. It…

  • How to use GPS in PowerApps.

    How to use GPS in PowerApps.

    Maps can be used to show contextual information to your users, reason for witch allowing you to represent location data…

    1 条评论

社区洞察

其他会员也浏览了