Next.js Run the Dev Server
The dev server shows the app in your browser while you work. Save a file, and the page updates on its own.
The page answers
The check asks the dev server for the home page. The answer is HTTP 200, which means it worked.
curl -s -o /dev/null -w "HTTP %{http_code}\n" http://localhost:3000/The starter text is on the page
The check reads the page text. The starter heading is there, so the server is serving the app.
curl -s http://localhost:3000/ | grep -o "To get started, edit the"Edit the page, and the new text shows up
One line in page.tsx changed, and the next check shows the new text. The server was never restarted.
curl -s http://localhost:3000/ | grep -o "My Bookshelf is open for reading"Example
npm run devKey points
- Dev server: a small server that shows the app while you build it
- npm run dev: the command that starts the dev server
- localhost:3000: the address of the app on your own computer
- Fast Refresh: the update that swaps a changed file into the open page without a reload
- Edit app/page.tsx and watch the page change. No restart is needed.
- Stop the server with Ctrl+C when you are done.
In this example, one command starts the dev server. The first two lines show the command and the tool it runs. The next lines name the version, 16.4.6, and the address, localhost:3000. The last line says the server is ready, after 5.6 seconds. The network address in the middle will differ on your own machine. Open the local address, and the starter page is there.
Note
The dev server is for building only. A finished app is built and served another way, later in this course.
Try it Yourself
Edit the code, then press Run.
Running is simulated · TypeScript Playground
Exercise
What address does the dev server use?