Next.js 14
Used by some of the world's largest companies, Next.js enables you to create full-stack Web applications by extending the latest React features, and integrating powerful Rust-based JavaScript tooling for the fastest builds.
Links, Courses and Tutorials about Next.js 14.
Deploy Next.js on Vercel
Host your Next.js 14 App for free
About Next.js 14
Why you want to use Next.js 14
Next.js 14 Playground
Test Server Components, Streaming and Layouts
Learn Next.js 14
Interactive Next.js 14 Tutorial
Templates
Start your app with a Template
Turbopack
Turbocharge your Next.js 14 App
Get help with Next.js 14 from the community or creators.
To bootstrap a new Next.js 14 project, run the following command:
npx create-next-app@latest my-app
my-app
directory, for example with VS Code.
code my-app
ESlint & Prettier
First, install Prettier:
npm install -D prettier eslint-config-prettier eslint-plugin-prettier
Next, extend your ESLint config:
{ "extends": ["next/core-web-vitals", "plugin:prettier/recommended"]}
.prettierrc.json
to your project:
{ "trailingComma": "es5", "tabWidth": 4, "semi": false, "singleQuote": true}
Shadcn UI
npx shadcn-ui@latest init
Leave all options on their default values. After this, you will be able to install UI components like Buttons, Accordions and Dropdown Menus as easy as:
npx shadcn-ui@latest add buttonnpx shadcn-ui@latest add accordionnpx shadcn-ui@latest add dropdown-menu
TS Reset
npm i -D @total-typescript/ts-reset
reset.d.ts
file anywhere in your project:
import '@total-typescript/ts-reset'
Server Components
app
directory are Server Components by default.Client Components
Client Components were the default until Next.js 14, and you still need them in Next.js 14 when you want to
- introduce interactivity (
onClick
,onChange
, ...) - use hooks like
useEffect
oruseState
You can make your component a client component by adding to the top of your file:
'use client'
Layouts
Root Layout
import { PropsWithChildren } from 'react'import type { Metadata } from 'next'import { Inter } from 'next/font/google'import './globals.css'const inter = Inter({ subsets: ['latin'] })export const metadata: Metadata = { title: 'Create Next App', description: 'Generated by create next app',}export default function RootLayout({ children }: PropsWithChildren) { return ( <html lang="en"> <body className={`min-h-screen flex flex-col ${inter.className}`}> <nav>Navbar</nav> <div className="grow">{children}</div> <footer>Footer</footer> </body> </html> )}
html
and body
tags.Route Segment Layout
import { PropsWithChildren } from 'react'export default function DashboardLayout({ children }: PropsWithChildren) { return ( <> <aside> <nav>Sidebar Nav</nav> </aside> <main>{children}</main> </> )}
/dashboard
) as well as all child routes (e.g. /dashboard/settings
)Pages
app/dashboard/page.tsx
, it will render the code for the route /dashboard
:
// `app/dashboard/page.tsx` is the UI for the `/dashboard` URLexport default function Page() { return <h1>Hello, Dashboard Page!</h1>}