nsyte run
Run a resolver server that serves nsites via npub subdomains. This command starts a local server that can resolve and serve nsites using the format npub1234.localhost or similar subdomain patterns.
Usage
nsyte run [npub] [options]Arguments
[npub](optional): Site identifier in various formats:naddr1...— NIP-19 naddr format (Kind 15128 or 35128)<name>.npub1...— Subdomain format for named sites (e.g.,blog.npub1...)npub1...— Regular npub for root site (Kind 15128)- If not provided, uses default demo site
Options
-r, --relays <relays>— Nostr relays to query (comma-separated)-p, --port <port>— Port number to run the resolver on (default: 6798)--sec <secret>— Secret for signing (auto-detects: nsec, nbunksec, bunker://, hex)-c, --cache-dir <dir>— Directory to cache files (default:/tmp/nsyteor%TEMP%\nsyte)--no-cache— Disable file caching entirely--use-fallback-relays— Include default nsyte relays for file discovery--use-fallback-servers— Include default blossom servers for file downloads--use-fallbacks— Enable both fallback relays and servers--no-open— Don't automatically open browser
Examples
Basic Resolver
nsyte runStarts the resolver on http://localhost:6798. Accessing localhost redirects to a demo npub. You can access any nsite at:
http://npub1abc123.localhost:6798http://npub1def456.localhost:6798
Launch Specific npub
nsyte run npub1abc123def456ghi789Launch with naddr
nsyte run naddr1...Launch Named Site
nsyte run blog.npub1abc123def456ghi789Custom Port and Cache
nsyte run -p 8080 -c /custom/cacheDisable Cache
nsyte run --no-cacheDon't Auto-Open Browser
nsyte run --no-openStarts the resolver and when you access localhost, it will redirect to the specified npub instead of the default demo.
Custom Port
nsyte run --port 3000Serves on port 3000 instead of the default 6798.
Custom Relays
nsyte run --relays wss://relay1.com,wss://relay2.comUses specific relays for discovering nsite events.
How It Works
The resolver server:
- Subdomain Parsing: Extracts npub from subdomain (e.g.,
npub1abc123.local.dev) - Event Discovery: Fetches site manifest events (kinds 15128, 35128) from configured relays
- File Resolution: Maps requested paths to file hashes from events
- Blob Serving: Retrieves and serves files from blossom servers
- Fallback Handling: Serves fallback content for client-side routing
Subdomain Format
The resolver expects npub subdomains in the format:
npub1[bech32-encoded-pubkey].[base-domain]Examples:
npub1abc123def456.localhost:3000npub1xyz789uvw012.local.dev:6798
DNS Setup for Production
For production use, you'll need to configure DNS:
Wildcard DNS
Set up a wildcard DNS record pointing to your server:
*.nsites.example.com → 1.2.3.4Local Development
For local testing, add entries to /etc/hosts:
127.0.0.1 npub1abc123.localhost
127.0.0.1 npub1def456.localhostOr use a service like lvh.me which resolves all subdomains to localhost.
Configuration
Relay Configuration
The resolver uses relays to discover nsite events:
# Use default relays
nsyte run
# Use specific relays
nsyte run --relays wss://relay.nsite.lol,wss://relay.damus.ioBlossom Server Configuration
Configure blossom servers via .nsite/config.json or enable defaults with --use-fallback-servers. The run command does not accept a --servers flag — the resolver reads the configured server list from your project config (or from the manifest itself when serving an arbitrary site).
# Use servers from the project config
nsyte run
# Add the default nsyte blossom servers as a fallback
nsyte run --use-fallback-servers
# Enable both relay and server fallbacks
nsyte run --use-fallbacksFeatures
Automatic Discovery
- Discovers nsite events from relays automatically
- Caches event data for better performance
- Updates when new events are published
File Serving
- Serves files directly from blossom servers
- Handles content types appropriately
- Supports range requests for large files
SPA Support
- Respects fallback configuration from nsite events
- Enables client-side routing for React, Vue, etc.
- Serves index.html for unmatched routes (when configured)
Error Handling
- Returns 404 for non-existent nsites
- Handles blossom server failures gracefully
- Provides helpful error messages
Performance Considerations
Caching
The resolver caches:
- Event data from relays
- File mappings
- Blossom server responses (where appropriate)
Scaling
For production deployment:
- Use a reverse proxy (nginx, Cloudflare)
- Implement additional caching layers
- Monitor relay and blossom server performance
Reliability
- Configure multiple relays for redundancy
- Use multiple blossom servers for failover
- Implement health checks
Production Deployment
nsyte run always binds to localhost. There is no --host flag. To expose the resolver beyond localhost in production, run it behind a reverse proxy (nginx, Caddy, Cloudflare, etc.) that listens on a public interface and forwards to localhost:<port>.
Nginx Reverse Proxy
server {
server_name *.nsites.example.com;
location / {
proxy_pass http://localhost:6798;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}systemd Service
[Unit]
Description=nsyte resolver
After=network.target
[Service]
Type=simple
User=nsyte
WorkingDirectory=/opt/nsyte
ExecStart=/usr/local/bin/nsyte run --port 6798
Restart=always
[Install]
WantedBy=multi-user.targetMonitoring
Health Check Endpoint
The resolver typically provides a health check endpoint:
GET /_healthMetrics
Monitor these metrics:
- Request latency
- Cache hit rates
- Relay response times
- Blossom server availability
Troubleshooting
Subdomain Not Resolving
- Check DNS configuration
- Verify npub format is correct
- Ensure the nsite has published events
Files Not Loading
- Check blossom server availability
- Verify file hashes in events
- Test blossom servers directly
Performance Issues
- Check relay response times
- Monitor blossom server latency
- Review caching configuration
Related Commands
nsyte serve- Serve local files for developmentnsyte deploy- Deploy files to create nsitesnsyte debug- Debug nsite configuration and connectivitynsyte ls- List published nsite files
Inherits global options. See global options.