> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bachs.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Money is always a decimal string at the currency's precision (for example "29.00"), paired with an ISO 4217 currency field. Never use minor units.
> Build against the sandbox first: base URL https://sandbox-api.bachs.io with sk_sandbox_ keys. Production is https://api.bachs.io with sk_live_ keys; going live is a key swap.
> Treat webhooks (for example collection.succeeded) as the source of truth for fulfilment, never client-side events or redirects.
> Subscriptions are created by completing a checkout for a recurring product. There is no direct create-subscription endpoint.
> IDs carry resource prefixes (cust_, prod_, sub_, chk_, inv_, ref_) and timestamps are ISO 8601 UTC.

# Starter templates

> Choose working starter code by framework and use case, run it in the Bachs sandbox, and adapt it to your product.

Start a new app with a working Bachs integration. Choose a template for your framework and the payment flow your product needs, then follow its setup instructions and test it in the sandbox.

## Available templates

| Template | Framework | Use case | Included |
| - | - | - | - |
| [Next.js SaaS](https://github.com/bachsdev/bachs-nextjs-saas) | Next.js App Router, TypeScript | Subscription access | Monthly and yearly checkout, verified webhooks, access checks, customer portal, and automated tests |

### Next.js SaaS

Use this starter for a product that charges for ongoing access, such as a software tool or a membership app.

The starter uses the [official Bachs SDK](https://github.com/bachsdev/bachs-node) for checkout, product setup, customer portal sessions, and webhook verification. It saves subscription state and grants access after a verified webhook. A success redirect cannot grant access.

You need Node.js 22 or later, a [sandbox API key](/authentication), and the [Bachs CLI](/cli/overview). See the repository's [README](https://github.com/bachsdev/bachs-nextjs-saas#readme) for setup and SDK package instructions.

<Note>
  This is a local development starter. Every visitor shares a demo user, and billing data is stored in a local JSON file. Replace authentication and storage before deploying. Add your product's features and choose its access policy.
</Note>

## Start building

1. Open the [template repository](https://github.com/bachsdev/bachs-nextjs-saas) and select **Use this template** to create your own copy.
2. Follow its README to configure sandbox products, start the webhook listener, and run the app. Authenticate the CLI to the same sandbox account as the app.
3. Complete a sandbox checkout. Confirm that the webhook saves the subscription, access activates, and **Manage billing** opens the correct customer's portal.
4. Adapt the app to your product. Replace the demo components, run the included tests, and follow the [go-live checklist](/build/use-cases/saas-subscriptions#go-live-checklist).

For a fully local app, the starter leaves checkout return URLs unset. Return to the app manually after payment. Automatic return requires a public URL; webhook forwarding through the CLI still works locally.

## Learn the flow

* [SaaS subscriptions](/build/use-cases/saas-subscriptions): understand the objects, requests, webhook events, and access decisions used in this template.
* [Skills and prompts](/build/ai#sell-subscriptions): use a coding assistant to adapt subscription billing to your app.
* [Live demo](/demo): try other billing models in the sandbox.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.