CLI tool for deploying frontend code to Only-Once
npm install onlyonce-cliCommand-line tool for deploying frontend code to the Only-Once deployment service.
``bash`
npm install -g onlyonce-cli
Or use with npx (no installation needed):
`bash`
npx onlyonce-cli deploy
When no directory is provided, the CLI runs your project's build script andbuild
auto-detects common output directories (, dist, out, .next, public):
`bash`
npx onlyonce-cli deploy
`bash`
npx onlyonce-cli deploy ./build
npx onlyonce-cli deploy ./dist
npx onlyonce-cli deploy /path/to/your/build
`bash`
npx onlyonce-cli device-login # Create or refresh a device session
npx onlyonce-cli --version # Show version
npx onlyonce-cli --help # Show help
Set the Only-Once API URL via environment variable:
`bash`
export ONLY_ONCE_API_URL=http://localhost:3000
npx onlyonce-cli deploy
Or create a .env file:
`env`
ONLY_ONCE_API_URL=http://localhost:3000
Default API URL: http://localhost:3000
The CLI stores the device token and ID in ~/.onlyonce/config.json. Runningnpx onlyonce device-login refreshes this token and prepares the CLI for future
deployments.
1. Build: Runs your project's build script if a directory is not providedbuild
2. Auto-Detection: Finds common build directories (, dist, out, .next, public)
3. Zip: Archives the build output for upload
4. Deployment: Uploads the zip to the Only-Once API
5. Result: Returns the live CDN URL where your app is deployed
`bash`
npm run build
npx onlyonce-cli deploy ./build
`bash`
npm run build
npx onlyonce-cli deploy ./out
`bash`
npm run build
npx onlyonce-cli deploy ./dist
`bashBuild your app
npm run build
Requirements
- Node.js 18+
- Only-Once server running (see only-once)
- Built frontend project with
index.htmlTroubleshooting
$3
Make sure you're in the project root and have built your project, or specify the directory manually:
`bash
npx onlyonce-cli deploy ./build
`$3
1. Make sure the Only-Once server is running
2. Check the API URL:
export ONLY_ONCE_API_URL=http://your-server:3000
3. Verify network connectivity$3
Make sure you're deploying the built/compiled output, not the source code. Most frameworks require a build step:
`bash
npm run build # or yarn build, etc.
npx onlyonce-cli deploy ./build
``ISC