Storing Delivery Fees and Store Settings in the Database Instead of Code with Next.js
The author argues that business-driven values such as delivery fees, free-delivery thresholds, and opening hours should not be hardcoded but kept in a database. They describe ramo.co.il, a Next.js garden-tools store, where settings live in a key/value table with a JSON column while secrets stay in environment variables. Reads are wrapped in a cached loader that converts raw data into typed objects and falls back to safe defaults if the database fails. Saving a setting through an admin screen triggers tag-based revalidation so changes take effect without a deployment. The approach also includes schema validation of values and an audit trail, with the server computing fees so the cart and checkout use the same source of truth.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in