Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To preview an Astro directory locally as it will be built for deployment, run the project’s build command and then astro preview. Astro writes static output to dist/ by default. For a preview URL teammates can open, use your host’s branch or deploy preview workflow instead; the local preview server is for checking builds, not production hosting.

Choose the kind of preview you need

Need Use What it shows
Check your own edits while coding Astro development server The current source, with updates as you edit.
Check the generated site on your computer astro build, then astro preview The most recent completed build, typically from dist/.
Share a review link with a teammate or client A host’s branch or deploy previews A remotely accessible deployment, subject to the host and repository configuration.

These serve different purposes: the development server follows source changes, whereas astro preview serves built output. See Astro’s development and build guide and CLI reference.

Preview the built directory locally

  1. Run the development server while editing. Use your project’s usual development command. Astro watches source changes, making this the convenient option for iterative work.
  2. Build the site. Stop the dev server if needed, then run the project’s build script from its root. For a common npm setup, the command is npm run build. Other package managers may use their own equivalent script.
  3. Serve the completed build. Run astro preview, or the preview script configured in the project, then open the local address printed in the terminal.
  4. Rebuild after source edits. Preview serves the last completed build; it does not update to reflect edits until you build again.
npm run build
npx astro preview

If your project already defines a preview script, use it instead, for example npm run preview. Check the project’s scripts if you are unsure. Astro’s CLI reference documents the preview command and its options.

What you are inspecting

Astro’s default output is static, and the generated directory is dist/ unless the project changes its output configuration. The local preview lets you check the result of the build rather than only the live development server. It is intended for local checking, not as a production hosting server. See Astro’s deployment guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Give reviewers a shareable preview URL

For remote review, connect the repository to a hosting provider and configure its preview deployment workflow. The host builds and publishes a preview according to the repository and provider settings. A local astro preview URL is not a substitute for a hosted review link.

Vercel

Astro’s Vercel guide describes Git integration in which branch pushes create Preview Deployments after the repository is imported; changes to the configured production branch generate production deployments. See Astro on Vercel.

Netlify

Astro’s Netlify guide describes repository changes triggering preview and production deploys according to the deployment configuration. The documented common static build command is astro build (or npm run build), with dist as the publish directory. See Astro on Netlify.

Provider choice depends on the review workflow you want and your deployment configuration; the Astro documentation does not establish one universal winner. Confirm the provider’s build command and output-directory settings, particularly if you use a monorepo or have changed Astro’s outDir.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check whether the directory can be static

Astro prerenders the entire site by default, so a directory that can be generated at build time can generally use the static build and preview workflow above. If pages need on-demand rendering, configure server output and the appropriate adapter for the target host or runtime. See Astro’s on-demand rendering guide and deployment guide.

Troubleshoot preview problems

  • Your preview does not include recent edits: You are likely viewing the last completed build. Run the build command again, then reload the preview.
  • The preview command cannot be found: Run it from the Astro project root and check that Astro is installed in the project. If the repository defines a preview script, use that script or invoke the project’s Astro CLI through its package manager.
  • The build fails before preview starts: Fix the build error first; preview serves generated output and cannot replace a successful build. Check the terminal output for the failing route or build step.
  • The host cannot find the generated site: Verify the repository root, build command, and publish/output directory in the host settings. The common static defaults are astro build or npm run build and dist, but project configuration may differ.
  • A route works locally but not in the hosted build: Compare the built output and host configuration, including any base path or adapter settings. If the route requires server-side, on-demand rendering, ensure the site is configured with a compatible adapter and server output.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need an image of a deployed directory page rather than a local build preview, ScreenshotNeo can capture a URL with one request. It is a website screenshot API and MCP server for developers. For example, this cURL request saves a WebP screenshot of the target page:

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.18
SaleBestseller No. 2
SaleBestseller No. 4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

Replace https://example.com with the deployed page URL and YOUR_API_KEY with your key. See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.