Coder Social home page Coder Social logo

-'s Introduction

Next.js 14 Hello World

Download and Install Node.js LTS Version

Download and Install VS Code

Check out the Next.js 14.0.2 Installation Docs Watch Next.js 14 - How to install and deploy

  1. Create a new Folder

  2. Open the Command Line (Terminal) and run this command:

npx create-next-app@latest

this will create a Next.Js project

The app directory is where you define routes, create UI and colocate files such as components, tests, or stylesheets.

Read the following React Documentation:

React Essentials

Note: Our file extension is not jsx but tsx because we are using TypeScript

  1. In the app/page.tsx file delete the previous React component and replace it with the following simple hello world component:
export default function Home() {
  return (
        <div>Hello World</div>
  );
}

We wrote a very simple hello world React component in the file. Note that it is a convention in Next.js that the html page in the director is called page.tsx

  1. Start the development Server:
npm run dev
  1. Open http://localhost:3000 with your browser to see the results locally.

The page auto-updates as you edit the file.

Note that the development server created a layout.tsx file by itself even if you delete it. This means the Next.js requires that there must be RootLayout component in the app folder for the app to function.

The app/layout.tsx and app/page.tsx files will be rendered when the user visits the root of your application.

The file app/layout.tsx is used to define UI that is shared across multiple pages. A layout accepts another layout or a page as its child. You can nest layouts to create nested routes.

The file app/page.tsx is used to define the unique UI of a route. Pages represent the leaf of the route and are needed for the path to be accessible.

Manual Deployment through CLI

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

npm i -g vercel

Now go to the Next.js project directory and give the following command to deploy to cloud:

vercel

In my case the web app is deployed to:

    https://step00-helloworld.vercel.app

Check out our Next.js deployment documentation and Vercel CLI Docs for more details.

Project config with vercel.json

vercel.json

example

Rewrite Example

Learn More

This is a Next.js project bootstrapped with create-next-app.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

-'s People

Contributors

typescriptkamran avatar

Watchers

 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.