astrolock write
Starts a development server with live reload for rapid iteration while building your site.
Usage
astrolock write
What It Does
The development server:
- Starts local server on http://localhost:4321
- Watches for changes to content and configuration
- Live reloads browser when files change
- Shows detailed errors to help debug issues
- Fast rebuilds only changed files
$ astrolock write
Starting Astrolock development server...
β Configuration loaded
β Processing content...
β Server started
π Server running at http://localhost:4321
Press Ctrl+C to stop
[11:23:15] Content updated: blog/my-post.md
[11:23:15] Page regenerated in 234ms
[11:23:15] Browser reloadedLive Reload
When you change files, the browser automatically reloads:
What Triggers Reload
- β
Content files (
.md,.mdx) - β
Configuration files (
config/*.json) - β Style files (CSS)
- β JavaScript files
What Doesnβt Trigger Reload
- β Media files in
public/(requires manual refresh) - β
.envfiles (requires server restart)
Tip
For media file changes, do a hard refresh: Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac).
Development Workflow
# 1. Start dev server
astrolock write
# 2. Open browser
# Visit http://localhost:4321
# 3. Edit content
# Open content/blog/my-post.md in your editor
# 4. Save file
# Browser automatically reloads with changes
# 5. Check changes
# No need to refresh - it's automatic!
# 6. Stop server when done
# Press Ctrl+CDevelopment vs Production
| Feature | write (Dev) | build (Prod) |
|---|---|---|
| Build time | 3-5s | 8-15s |
| Optimization | Minimal | Full |
| Source maps | Yes | No |
| Hot reload | Yes | No |
| Error detail | Verbose | Minimal |
Info
Use write for active development, build for final testing and deployment.
Port Configuration
The server uses port 4321 by default. If busy, it tries 4322, 4323, etc.
$ astrolock write
Port 4321 is in use, trying 4322...
π Server running at http://localhost:4322
Troubleshooting
- Server Won't Start
- Port in Use
- No Reload
- Memory Error
Error: Cannot find module 'astro'Fix: Install dependencies:
cd /path/to/astrolock
yarn installError: Port 4321 is already in useFix: Kill the existing process:
lsof -ti:4321 | xargs kill -9Or let Astrolock auto-select the next port.
Possible causes:
- Browser cache - Hard refresh
- File not saved
- Server stopped
Fix: Restart server:
# Press Ctrl+C, then
astrolock writeError: JavaScript heap out of memoryFix: Increase memory:
NODE_OPTIONS="--max-old-space-size=4096" astrolock writeError: Cannot find module 'astro'Fix: Install dependencies:
cd /path/to/astrolock
yarn installError: Port 4321 is already in useFix: Kill the existing process:
lsof -ti:4321 | xargs kill -9Or let Astrolock auto-select the next port.
Possible causes:
- Browser cache - Hard refresh
- File not saved
- Server stopped
Fix: Restart server:
# Press Ctrl+C, then
astrolock writeError: JavaScript heap out of memoryFix: Increase memory:
NODE_OPTIONS="--max-old-space-size=4096" astrolock writeMemory Usage
- Small sites: ~200MB
- Medium sites: ~400MB
- Large sites: ~800MB
Build Speed
- Initial build: 3-5s
- Incremental rebuilds: 100-500ms
- Full page reload: 200-300ms
# With Docker
docker run -p 4321:4321 -v $(pwd):/site astrolock writeStopping the Server
Press Ctrl+C in the terminal:
Stopping development server...
β Server stopped gracefully
Best Practices
- Keep server running while editing - donβt restart for each change
- Use multiple terminals - one for server, one for editing
- Hard refresh for media -
Ctrl+Shift+Rafter adding images - Monitor terminal - watch for errors and warnings
See Also
- astrolock build - Production build
- astrolock preview - Preview production build
- astrolock content - Create content
Tip
Keep astrolock write running while editing - it automatically reloads your browser!