![]() |
VOOZH | about |
Server Components in Next.js are rendered on the server, reducing the JavaScript sent to the browser and improving performance with faster initial page loads.
export default function ServerComponents(){
return (
<div>
Hey I am Server Component
</div>
)
}Note: Server components were introduced in Next.js version 13
In Next.js, Server Components are rendered on the server during the initial request, allowing efficient HTML generation with minimal client-side JavaScript.
Static rendering in Next.js pre-renders pages at build time, generating static HTML files for faster and more efficient delivery.
Dynamic rendering in Next.js renders pages on the server at request time, generating HTML dynamically based on the latest data.
Streaming in Next.js progressively sends UI from the server so content appears faster.
There are the many benefits of Server Side Rendering. I have explained some common Server Side Rendering.
To run the server component, we need to create Next.js Project.
Step 1: Create a project folder and move into it by using the below command in the terminal.
mkdir folderName
cd folderNameStep 2: In the foldername, create your project by using the the below command in the terminal or command prompt.
npx create-next-app@latest project_nameStep 3: After creating the folder, type the server component code in page.js file.
Example: We will fetch the data from "jsonplaceholder" for rendering the dynamic data in the client component.
Output :