Astro is a modern site builder with web best practices, performance, and DX front-of-mind.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Core CLI commands and programmatic APIs for building, developing, previewing, and managing Astro projects.
Builds the Astro project for production deployment.
/**
* Builds the Astro project for production
* @param inlineConfig - Configuration options for the build
* @param options - Build-specific options
* @returns Promise that resolves when build completes
*/
function build(inlineConfig: AstroInlineConfig, options?: BuildOptions): Promise<void>;import { build } from 'astro';
await build({
root: './my-project',
mode: 'production',
});Starts the Astro development server with hot module reloading.
/**
* Starts the development server
* @returns Promise that resolves with DevServer instance when server starts
*/
function dev(inlineConfig: AstroInlineConfig): Promise<DevServer>;
interface DevServer {
address: AddressInfo;
handle: (req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage>) => void;
watcher: vite.FSWatcher;
stop(): Promise<void>;
}import { dev } from 'astro';
const server = await dev({
root: './my-project',
server: {
port: 3000,
host: true,
},
});
await server.stop();Previews the production build locally before deployment.
/**
* Previews the production build
* @returns Promise that resolves with PreviewServer instance when server starts
*/
function preview(inlineConfig: AstroInlineConfig): Promise<PreviewServer>;import { preview } from 'astro';
await preview({
root: './my-project',
server: {
port: 4321,
},
});Generates TypeScript type definitions for Astro modules.
/**
* Generates TypeScript types for Astro modules (experimental)
* @returns Promise that resolves when sync completes
*/
function sync(inlineConfig: AstroInlineConfig): Promise<void>;import { sync } from 'astro';
await sync({
root: './my-project',
});Build-specific configuration options.
interface BuildOptions {
/**
* Output a development-based build
* @default false
*/
devOutput?: boolean;
/**
* Teardown the compiler WASM instance after build
* @default true
*/
teardownCompiler?: boolean;
}Server instance returned from the preview command.
interface PreviewServer {
host?: string;
port: number;
stop(): Promise<void>;
closed(): Promise<void>;
}Configuration object for programmatic API calls.
interface AstroInlineConfig {
/**
* Project root directory
* @default process.cwd()
*/
root?: string | URL;
/**
* Build mode
* @default 'development' for dev, 'production' for build
*/
mode?: 'development' | 'production';
server?: {
port?: number;
host?: string | boolean;
open?: boolean | string;
};
site?: string;
base?: string;
output?: 'static' | 'server';
trailingSlash?: 'always' | 'never' | 'ignore';
adapter?: AstroAdapter;
integrations?: AstroIntegration[];
vite?: ViteUserConfig;
}# Development server
astro dev [root]
--port <number> Port to run dev server on (default: 4321)
--host [address] Network address to listen on
--open Open browser on server start
--mode <mode> Build mode (default: development)
--force Force rebuild
--allowed-hosts <hosts> Allowed hosts for CORS
# Production build
astro build [root]
--outDir <directory> Output directory (default: dist)
--mode <mode> Build mode (default: production)
--devOutput Output development-style build
--force Force rebuild
# Preview production build
astro preview [root]
--port <number> Port to run preview server on (default: 4321)
--host [address] Network address to listen on
--open Open browser on server start
--allowed-hosts <hosts> Allowed hosts for CORS
# Type generation
astro sync [root]
--force Force regeneration
# Add integrations
astro add <integration>
# Type checking
astro check
# Show environment info
astro info
# Configure telemetry
astro telemetry [enable|disable|reset]
# Configure preferences
astro preferences list
astro preferences set <key> <value>
astro preferences reset <key>Astro respects several environment variables:
NODE_ENV - Set to 'production' or 'development'ASTRO_TELEMETRY_DISABLED - Set to '1' to disable telemetryASTRO_CONFIG_FILE - Custom config file locationPUBLIC_* - Environment variables prefixed with PUBLIC_ are available to client-side code--port or in your config.--force to clear cache and rebuild from scratch.astro sync manually to regenerate types if IDE completion is stale.