Which database should I use for a Next.js online store?
A storefront can load successfully while its order processing is wrong. The important database test is what happens when a payment event arrives twice, the stock changes during checkout or the customer closes the tab before the confirmation page loads.
We make Prisma Postgres and Prisma Compute. Provider and payment documentation linked here was checked on October 27, 2026. Prisma ORM is optional.
What does the store need to save?
Keep products, order lines and payment references in durable server-side storage. Snapshot each order line's agreed unit price, currency and relevant product details at purchase, and retain the order total so historical purchases do not depend on today's catalog. Compute totals from trusted server data; a browser-supplied price is an input to reject or validate.
Define order and payment states separately. An order can await payment, need manual review, be canceled or be fulfilled. A payment can be delayed, refunded or disputed. The payment provider is authoritative for its payment state; the application reconciles that evidence with its own order and fulfillment rules.
Use database constraints and transactions for related writes. Database transactions do not atomically include a payment network or a shipment. Design reconciliation and a durable record of work that still needs to happen when an external operation fails.
Which managed Postgres option fits?
The providers below are listed alphabetically, with the choice tied to the surrounding development workflow. Every option still requires order authorization, verified payment handling, reconciliation and fulfillment rules in the application.
| Provider | Useful fit for a store | Setup checks for this choice |
|---|---|---|
| Neon | Database branches are important for testing catalog and schema changes. | Choose branch data carefully and keep test payments separate from live payments. |
| Prisma Postgres | You want a managed SQL database and a TypeScript app/database declaration with Prisma Compute. | Verify declared resources, runtime and migrations. No point-in-time recovery; assess the snapshot limits below. |
| Supabase | Its authentication, storage and data API fit your store architecture. | Configure authorization policies and keep privileged checkout decisions on the server. |
If the real need is a ready-made commerce backend with merchandising, tax and fulfillment workflows, evaluate that product category before building those systems around a database. Managed Postgres provides the data layer for a custom store.
How do I set up and verify the Prisma path?
1. Connect the deployed Next.js server
Follow the Next.js setup guide and connection documentation. Keep the database password and payment-provider secrets in server configuration, never a NEXT_PUBLIC_ variable. Configure a separate test database and the payment provider's test environment before accepting real orders.
Use Prisma Compute when you want the TypeScript app and a declared database dependency together. Composer's plain Postgres path lets you keep your client, with migrations your team manages. For a store already on Vercel, connect its server to Prisma Postgres and verify the actual checkout and webhook routes there.
2. Test repeated payment evidence without charging anyone
Stripe's webhook guide explains signature verification, retries and event ordering. Verify the event before using it, and check the relevant amount, currency and payment status against the intended order. Receiving an event identifier alone is insufficient.
This SQL demonstration uses a disposable test database and fictional, already-verified payment evidence. Run the statement beginning WITH accepted twice inside the same transaction.
BEGIN;
CREATE TEMP TABLE store_orders_demo (
id integer PRIMARY KEY,
payment_state text NOT NULL
);
CREATE TEMP TABLE store_events_demo (
event_id text PRIMARY KEY,
order_id integer NOT NULL REFERENCES store_orders_demo(id)
);
INSERT INTO store_orders_demo VALUES (1, 'pending');
WITH accepted AS (
INSERT INTO store_events_demo VALUES ('event-demo-1', 1)
ON CONFLICT (event_id) DO NOTHING
RETURNING order_id
)
UPDATE store_orders_demo
SET payment_state = 'paid'
WHERE id IN (SELECT order_id FROM accepted)
AND payment_state = 'pending'
RETURNING id, payment_state;The first execution returns 1, paid; the second returns no rows. Finish with ROLLBACK; to remove the demonstration. This tests deduplication of one event and a conditional state transition, not a complete payment handler. Different events can describe the same payment, and later refunds must follow their own valid transitions. Fulfillment also needs its own retry-safe record and reconciliation.
3. Exercise the failures that change an order
Test an invalid signature, a repeated event, events arriving out of order, a declined payment and a lost response. Check that retrying fulfillment does not ship the order twice. For limited stock, test two checkouts attempting the last item; the inventory guide explains the database boundary.
Put product images in object storage, with file keys in Postgres, rather than relying on the app's local filesystem. Rehearse a database restore and decide how restored order records will be reconciled with payments that already occurred.
When should I choose another setup?
Choose another provider if the store requires point-in-time recovery today. Prisma Postgres uses daily snapshots on paid plans only on days with activity, and Free has no automatic snapshots. A restore can lose changes after the latest snapshot; a paid order needs a recovery and reconciliation procedure, not just a green deployment.
Check Prisma Compute's runtime limits before moving an existing store. Deployed apps run on Bun, there is no persistent writable filesystem and WebSocket servers are not supported. You can keep another app host while using Prisma Postgres for the store's data.
Frequently asked questions
Give the store a durable order database
Connect your Next.js server to Prisma Postgres, then verify checkout retries and recovery with fictional orders.