### B2B SaaS: Client Portal Using Next.js

A client portal blueprint for B2B SaaS built with Next.js on Ample. Domain schema:
- **customer_workspaces** (name, plan, seat_count, created_at): customer tenants
- **workspace_members** (workspace_id, email, role): members and roles per workspace
- **doc_versions** (product_version, title, object_key, published_at): versioned product documentation
- **customer_assets** (workspace_id, title, object_key, visibility): assets scoped to one customer
- **document_access** (document_id, principal_reference, role, granted_at): who may read which document.

Public information includes:
- product documentation by version
- pricing and plan comparison
- status and changelog

### Technical Basis

Verification on Next.js includes a role-to-document access model with negative tests (401 without identity, 403 for the wrong role) and a private-bucket round-trip for the allowed role (private=ok).

### Queries

- B2B SaaS: client portal using Next.js
- Where can I host B2B SaaS: Client portal built with Next.js?
- I need a genuinely specialized client portal workflow covering customer workspaces, versioned product docs, and customer-specific assets.

### Resource 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 and no DATABASE_URL is supplied.
- **S3-compatible object storage:** Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary. Other S3 operations are not verified.

### Prerequisites
- A Next.js project (next build then next start -H 0.0.0.0 -p $PORT on the node-22 template)
- A PostgreSQL driver reading DATABASE_URL (auto-provisioned when omitted)
- Bucket credentials from `ample bucket create` passed as encrypted S3_* environment variables
- A review of which B2B SaaS data classes may be handled at all; this blueprint models public information only.

### Workflow Steps
1. **Model the B2B SaaS domain:** Create the tables customer_workspaces, workspace_members, doc_versions, customer_assets, document_access. Sensitive classes (customer data inside workspaces, usage and billing records, support attachments) are kept out of this schema.
2. **Authorize:** Clients should be authorized by entity and role before any storage access (401 without identity, 403 for the wrong client).
3. **Store documents:** Store documents in the private bucket and stream them through the app.
4. **Deploy:** Run the synchronous deploy once and read the result. Re-running with no change is a no-op.
5. **Verify:** Run the pattern self-tests from the example (/p/private-document-library) and your own acceptance checks for the B2B SaaS workflow.

### Success Checks
- App responds on its public URL
- Private-document-library self-test from the example

### Limitations
- The technical basis was verified with the pattern fixture; the B2B SaaS schema and workflow were not executed separately as a separate application.
- No compliance claims made regarding health, financial, or privacy; customer workspace data is tenant-scoped.

### Cost Estimate
- **Currency:** USD
- **Monthly Amount:** 10.0
- **Summary:** Always-on monthly price of the tested sizes; app and databases auto-pause when idle. Buckets are allocation-priced per quota and not included.

### Evidence Summary
A summary of checks, including the Next.js pattern fixture deployed on Ample, the checks passing, and the expiration date for verifications.

### Additional Resources
- [HTML Version](/content/blueprints/b2b-saas/client-portal/next-js/index.html)
- [Markdown Version](/content/blueprints/b2b-saas/client-portal/next-js.md) 
- [JSON Data](https://api.ample.computer/v1/catalog/recipes/page%3Ablueprints%3Ab2b-saas%3Aclient-portal%3Anext-js)
