## 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:
1. **Build and start**: `next build` then `next start -H 0.0.0.0 -p $PORT` on the node-22 template. The server must bind 0.0.0.0 on PORT.
2. **Implement the pattern on PostgreSQL**: Content-type and size validation that rejects disallowed files, object linking, keep migrations idempotent.
3. **Wire object storage**: Create the bucket(s), pass endpoint, region, bucket, and keys as --env values.
4. **Deploy**: Run the synchronous deploy and read the result.
5. **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:
1. Browse the catalog index.
2. Search published recipes by intent, stack, and constraints.
3. Prepare a side-effect-free deployment plan for an authorized project.
