Primary commands
div new
Spin up a fresh project and start the dev server in one go.
div new is the moment a new website comes to life. It creates a fresh folder, drops in a starter index.html, writes a div.json manifest and a .divignore, and fires up the local dev server — all in one command.
#Synopsis
div new <name> [options]
#What it does
div new creates a new directory called <name>, writes a starter index.html, a div.json manifest, and a .divignore template into it, and then starts the local dev server (the same one you'd get from div start) inside the new folder. By default it also opens the URL in your browser, so you can see your starter page right away.
Heads up — the slug for your eventual public URL is not chosen here. Slugs get allocated server-side on your first deploy. The folder name is just a starting point for that slug — div new my-cool-site creates a folder named my-cool-site and, on first deploy, asks the server for a slug like my-cool-site-a4f9d2. Nice and tidy.
#Options
| Flag | What it does |
|---|---|
-p, --port <port> |
Port for the dev server. Defaults to 3000; auto-increments if it's taken. |
-h, --host <host> |
Host to bind to. Defaults to 127.0.0.1 (just your machine). |
--no-open |
Skip opening the browser. |
#Examples
Scaffold and run on the default port:
div new portfolio
Scaffold but don't open a browser tab (handy if you've already got one):
div new portfolio --no-open
Bind the dev server to all network interfaces so your phone on the same wifi can see your work:
div new portfolio --host 0.0.0.0
A quick warning on
--host 0.0.0.0: this exposes your work-in-progress to anything on the same network. Only do this when you actually want to share with someone on your wifi.
#What gets created
After div new portfolio does its thing, your folder looks like this:
portfolio/
├── .divignore
├── div.json
└── index.html
index.html is a minimal starter page — easy to throw away, easy to build on. div.json looks like:
{
"slug": null,
"createdWith": "div@<version>"
}
slug stays null until your very first div deploy.
.divignore is a commented template — the built-in defaults (node_modules, .git, .DS_Store, .env*, div.json, *.log) are always applied, so the file just shows you the syntax and a few example patterns to uncomment. See .divignore for the full reference.
#After scaffolding
The terminal window running div new doubles as your dev server. Keep it open, edit files in your shiny new folder, and the browser will reload itself. When you're ready to publish to the world, open a second terminal and run div deploy from inside the folder.
#See also
div start— the dev server, on its own.div deploy— publish your folder to the world.div.json— the manifest format, in detail.