dev() function starts Astro’s development server. This is a local HTTP server that uses Hot Module Replacement (HMR) to update your browser as you save changes.
Import
Signature
Parameters
AstroInlineConfig
required
Configuration object for your Astro project. Supports all options from
astro.config.mjs.string
The root directory of your Astro project. Defaults to the current working directory.
'debug' | 'info' | 'warn' | 'error' | 'silent'
default:"'info'"
Controls the verbosity of logging output.
string
Your site URL. Used for generating URLs during development.
string
default:"'/'"
The base path your site is served from.
object
Server configuration options.
number
default:"4321"
The port the dev server listens on. If already in use, Astro will try the next available port.
string | boolean
default:"false"
Set which network IP addresses the server listens on. Set to
true to listen on all addresses including LAN and public addresses.string | boolean
default:"false"
Controls whether the dev server opens in your browser on startup. Pass a URL string or pathname to specify what to open.
Return Value
Returns aPromise<DevServer> that resolves to a server object with the following properties:
AddressInfo
Information about the server’s address, including port and host.
number
The port the server is listening on.
string
The address the server is listening on.
(req, res) => void
Request handler function. Can be used to integrate with other Node.js servers.
FSWatcher
Vite’s file system watcher instance. Can be used to watch for file changes.
() => Promise<void>
Stops the dev server and cleans up resources.