Next.js Tutorial
Selected Reading
- Next.js - Discussion
- Next.js - Useful Resources
- Next.js - Quick Guide
- Next.js - CLI
- Next.js - Deployment
- Next.js - Environment Variables
- Next.js - Typescript
- Next.js - Response Helpers
- Next.js - API MiddleWares
- Next.js - API Routes
- Next.js - Shallow Routing
- Next.js - Imperitive Routing
- Next.js - Dynanic API Routes
- Next.js - Routing
- Next.js - Pre-Rendering
- Next.js - Global CSS Support
- Next.js - CSS Support
- Next.js - Meta Data
- Next.js - Static File Serving
- Next.js - Pages
- Next.js - Environment Setup
- Next.js - Overview
- Next.js - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Next.js - CLI
Next.js - CLI
NEXT.JS provides a CLI to start, build and export apppcation. It can be invoked using npx which comes npm 5.2 onwards.
CLI Help
To get pst of CLI commands and help on them, type the following command.
npx next -h Usage $ next <command> Available commands build, start, export, dev, telemetry Options --version, -v Version number --help, -h Displays this message For more information run a command with the --help flag $ next build --help
Build Production Ready Build
Type the following command.
npx next build info - Loaded env from D:Node extjs.env.local Creating an optimized production build Compiled successfully. Automatically optimizing pages Page Size First Load JS + ? / 2.25 kB 60.3 kB + /_app 288 B 58.1 kB + /404 3.25 kB 61.3 kB + ? /api/user + ? /posts/[id] 312 B 61.6 kB + + /posts/one + + /posts/two + ? /posts/env 2.71 kB 60.8 kB + ? /posts/first 374 B 61.7 kB + First Load JS shared by all 58.1 kB + static/pages/_app.js 288 B + chunks/ab55cb957ceed242a750c37a082143fb9d2f0cdf.a1a019.js 10.5 kB + chunks/framework.c6faae.js 40 kB + runtime/main.60464f.js 6.54 kB + runtime/webpack.c21266.js 746 B + css/9706b5b8ed8e82c0fba0.css 175 B ? (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps) (Static) automatically rendered as static HTML (uses no initial props) ? (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
Build and Start Development Server
Type the following command.
npx next dev ready - started server on http://localhost:3000 info - Loaded env from D:Node extjs.env.local event - compiled successfully
Start the production Server
Type the following command.
npx next start info - Loaded env from Node extjs.env.local ready - started server on http://localhost:3000Advertisements