Lets obtaining Started with Next.JS for the longer term of internet development
The Next.js frontend framework has been around for less than some of years, however it's already one in all the foremost in style tools within the React system.
Next.js offers you the most effective developer expertise with all the options you would like for production: hybrid static & server rendering, matter support, smart-bundling, route prefetching, and more. No demand for any configuration.
Next.js will facilitate U.S.A. improve the performance, UX, and SEO of the online app.
Next.js takes inspiration from React, web-pack, and babel. it's a tool for making internet applications and is known for server-side rendering.
Server-Side Rendering(SSR) & Server-Side Generation(SSG) with NEXT.JS
Next.js became widespread as a result of it solved a retardant that several internet developers accustomed have with internet applications rendered on the client-side (in the browser).
The Single Page Applications (SPAs) don't need reloading from the user and supply extra interactivity. SPAs facilitate with up wife.
Next.js provides associate degree out-of-the-box resolution for server-side rendering (SSR) of React elements. With Next.js, developers will render the JavaScript code on the server and send straightforward indexable hypertext mark-up language to the user. problems associated with caching, server load, on-demand content, or the applying design needed plenty of tweaking.
Next.js took away all the work therefore you'll dedicate some time to the business logic of your application.
Next.js also can assist you with static website generation (SSG) — another SEO-friendly manner of building websites and applications. during this case, instead of throughout runtime, your hypertext mark-up language generation takes place throughout build time. once a page is requested, the user receives a pre-made static hypertext mark-up language page. a web site like this is often quite quick, however it’s virtually as appropriate as SSR for interactive internet applications that take plenty of user input as a result of it wants reconstruction for each new request. As a result, it’s a stronger selection for straightforward applications (such as blogs) within which the content sort doesn’t modification supported the user’s actions.
Static web site Generation
If your web site has some static content that is unlikely to alter fairly often (like your portfolio) then you don’t have to be compelled to worry concerning something. Next.js can mechanically do the SSG for you. as a result of it already is aware of what to render. therefore it generates the desired hypertext mark-up language sooner than time leading to an excellent quick expertise.
But in any serious internet application, we rely on some dynamic content that comes from some external API supply (your backend server). therefore however on earth Next.js can pre-render a page that depends on some external api data?
The thanks to do this may be a operate provided by NestJS named getStaticProps.
This is associate degree async operate that you just will come from your page. it'll deliver the results of some api decision sooner than time and pass the result as props to your page element.
So Next.js can resolve the mandatory props from within this operate sooner than time and pre-render your page. One vital issue to notice, you'll be able to solely come this operate from within your page kind element. You can’t outline it within the other element.
Use Case for SSG
You can solely use getStaticProps once you already understand the results of the api sooner than time. Here we have a tendency to ar victimisation JsonPlaceHolder api to fetch a listing of journal posts. In your home page, you already understand the api that you just ar aiming to decision to fetch all of your posts. it'll not rely upon some route parameter that may amendment on each request. therefore you'll be able to use getStaticProps it in a very situation like this.