Commerce
Catalog, inventory, orders and promotions for a shop, installed as one block.
Covers the order side of a shop: products and prices, stock, orders and discount rules. It matches what the commerce preset installed before it became a composite.
better-supabase add commerceexport default defineConfig({ blocks: { commerce: {} } });add lists commerce in blocks, writes the modules of every part and wires the client in lib/blocks.ts. Import the manifest from better-supabase/blocks/commerce when you build the set with createBlocks.
import { commerceBlock } from "better-supabase/blocks/commerce";Parts
Installing commerce installs these blocks. Each stays an ordinary block in the config and keeps its own client.
Helpers
payAndFulfil: Book the payment on an order, then fulfil every shipment line. A failed payment stops before anything ships.
await blocks.commerce.payAndFulfil({
orderId,
tracking: { trackingNumber: "1Z999" },
});processReturn: Settle a return by what happens to its units. restock receives them and puts tracked units back in stock, quarantine receives them without restocking so the app can inspect them first, and reject refuses the return. With refund, a received return is then refunded through orders.refund, linked to the return. A failed refund leaves the units received; retry it with orders.refund.
await blocks.commerce.processReturn({
orderId,
returnId,
disposition: "restock",
refund: true,
});The Next.js example calls it from the settleReturn server action in composite-actions.ts.
The helper returns a Result; each step is idempotent, so retrying after a partial failure is safe.
Remove
better-supabase remove commerce
better-supabase remove commerce --with-partsThe first command replaces commerce in blocks with its parts. The second removes the parts too, except any part another block still needs (remove).
Last updated on
Donations
Record one-off and recurring gifts from donors, post them on the ledger per fund or campaign, charge pledges through a payments provider once per period, and issue numbered tax receipts with a yearly summary.
Finance
Accounting, tax, banking and invoices, with a period close that reports what blocks it.