Deliver public assets through CDN for Next.js · Ample Computer
Deliver public assets through CDN for Next.js
Deliver public assets for a Next.js app through the Ample CDN. Publish a bucket with ample bucket publish, upload versioned assets with long-lived Cache-Control headers, and reference the bucket's public URL (public_url from ample bucket publish, https://
What it runs on
Compute Apps run in isolated x86_64 Firecracker microVMs; sizes are the priced VM sizes.
CDN A published bucket's objects are served from its public URL; set Cache-Control when uploading to control caching. App responses are served by the app.
You need
- A bucket created with
ample bucket createand published withample bucket publish(its public URL is the CDN base) - An S3 client in the app to upload assets under versioned keys
- An Ample account token with servers:write and buckets:write
Exact tested configuration
build
npm run build --if-present
install
npm install
runtime
node
sizes
1vcpu-1gb
start
npm run start
template
node-22
Steps
- Publish the bucket. Publishing makes objects readable at the CDN URL; keep private data in a separate, unpublished bucket.
$ ample bucket publish <bucket-name>
Upload versioned assets. Use keys such as assets/
/file and set Cache-Control: public, max-age=31536000, immutable; change the version to invalidate. Reference the CDN URL. Pass S3_PUBLIC_URL to the app and build asset URLs from it.
$ ample deploy . --name <app-name> --public --env S3_PUBLIC_URL=... --env S3_ENDPOINT=... --env S3_REGION=... --env S3_BUCKET=... --env S3_ACCESS_KEY_ID=... --env S3_SECRET_ACCESS_KEY=...
Verify delivery. Fetch /api/asset-url for the asset URL, then fetch that URL: the CDN must return the asset.
Verify. Fetch the live URL and run the success checks below. On failure read the build log, then the runtime log, fix the cause and deploy again; do not blind-retry.
$ ample logs <deployment_id> --kind build
How it was checked
✓ asset URL resolves through the CDN · http get /api/asset-url → “/assets/”
Evidence
November 6, 2026 · canary run Next.js route handler uploaded a versioned asset to a published bucket and returned its CDN URL; the CDN served the asset publicly.
November 5, 2026 · canary run ample bucket create issued credentials; PutObject and GetObject succeeded through the public S3 endpoint; publish exposed the object at its public URL with an ETag; unpublish and delete cleaned up.
Tested examples
- Next.js CDN assets canary. Versioned asset uploaded to a published bucket and served from the CDN URL.
What it doesn’t cover
- Verified on the node-22 template at s-1vcpu-1gb.
- Buckets speak the standard S3 API (PutObject and GetObject with path-style addressing are checked by the fixtures);
ample bucket upload-urlreturns presigned upload URLs. - Bucket credentials are passed as encrypted environment variables; the catalog never creates the bucket for you (use
ample bucket create). - Storage counts what you store, within your plan's allowance; the estimate below covers compute only.
- The CDN serves objects from published buckets; the app serves its own responses.
- Control caching with Cache-Control on upload and versioned asset keys.