page:recipes:form collection:next js:attachments
Host form collection with Next.js: file attachments
Deploy a form collection built with Next.js on Ample using the browser file uploads pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL, a private S3-compatible bucket holds objects with credentials delivered as encrypted environment variables.
Key Features:
- Verified on Next.js: content-type and size validation that rejects disallowed files.
- An object written to a private bucket and a row linking the record to the object key (reject=ok upload=ok linked=ok).
- Not separately tested: upload UI, allowed types, size limits and virus scanning; treat the form collection-specific behavior as your application code.
Representative Queries:
- Host form collection with Next.js: file attachments
- Where can I host Form collection built with Next.js?
- I need a restricted upload flow, file validation and record-to-object linkage.
Resource Requirements:
- Compute
- PostgreSQL
- S3-compatible object storage
Infrastructure Requirements:
- Compute: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- Postgres: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database.
- S3-Compatible Object Storage: Buckets are S3-compatible with issued credentials; operations verified by canary.
Framework:
- Next.js
Elaboration on Setup Steps:
- Build and start:
next buildthennext start -H 0.0.0.0 -p $PORTon the node-22 template. The server must bind 0.0.0.0 on PORT. - Implement the pattern on PostgreSQL: Content-type and size validation that rejects disallowed files, object linking, keep migrations idempotent.
- Wire object storage: Create the bucket(s), pass endpoint, region, bucket, and keys as --env values.
- Deploy: Run the synchronous deploy and read the result.
- Verify: Fetch the live URL and run your own checks.
Examples:
- Next.js pattern fixture: Multi-pattern app with browser file uploads module checked live, see source at
tests/deploy-canaries/_pattern-modules.
Success Checks:
- App responds on its public URL.
- Browser-file-uploads self-test.
Limitations:
- Verified only on the node-22 template at specific size configurations; other changes not verified.
Cost Estimate:
- Total Monthly Amount: $10.00
- App server (s-1vcpu-1gb) $5.00
- Managed PostgreSQL database (s-1vcpu-1gb) $5.00
Note:
Always-on monthly price of the tested sizes; buckets are priced per quota.
Next Actions:
- Browse the catalog index.
- Search published recipes by intent, stack, and constraints.
- Prepare a side-effect-free deployment plan for an authorized project.