# Host csv import tool with Next.js: file attachments

## Summary
Deploy a csv import tool 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. 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: your upload UI, allowed types, size limits and virus scanning; treat the csv import tool-specific behavior as your application code.

## Framework
Next.js

## Workload
CSV import tool

## Release Status
published

## Support Status
verified

## Execution Status
ready

## Prerequisites
- A Next.js project that builds and starts with the documented commands (next build then next start -H 0.0.0.0 -p $PORT on the node-22 template)
- A PostgreSQL driver reading DATABASE_URL at runtime (auto-provisioned when omitted, or supplied with --env)
- A bucket from `ample bucket create` with its credentials passed as encrypted S3_* environment variables
- An Ample account token with servers:write, databases:read, buckets:read

## Tested Configuration
- **Template**: node-22
- **Runtime**: node
- **Size**: s-1vcpu-1gb
- **Install**: npm install
- **Build**: npm run build --if-present
- **Start**: npm run start

## Input Schema
- **env**: Encrypted environment variables (bucket credentials, secrets)
- **name**: App name
- **path**: Project directory or ample.toml service
- **release_command**: Migration command run before activation

## Workflow 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**: Implements browser file uploads.
3. **Wire object storage**: Pass endpoint, region, bucket and keys as --env values.
4. **Deploy**: Run the synchronous deploy once and read the result.
5. **Verify**: Fetch the live URL and the pattern self-test route(s) from the example.

## Examples
- **Next.js pattern fixture**: Multi-pattern Next.js app whose browser file uploads module was checked live.

## Success Checks
- App responds on its public URL
- Browser-file-uploads self-test

## Limitations
- Verified on the node-22 template; other sizes, templates and Next.js versions are not verified.
- The csv import tool itself is application code and was not separately tested.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: $10.00
- **Components**:
  - App server: s-1vcpu-1gb, quantity: 1.0, monthly amount: $5.00
  - Managed PostgreSQL database: s-1vcpu-1gb, quantity: 1.0, monthly amount: $5.00
