{
  "version": "2",
  "id": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2",
  "title": "Developer Describes Moving Store Business Settings Out of Code and Into a Database on a Next.js Shop",
  "summary": "A dev.to author says his team at ramo.co.il keeps delivery fees, free-shipping thresholds and shop notices in a key/value settings table read through a cached, typed loader, so business changes no longer require a deploy.",
  "body": "A developer posting on dev.to under the handle elias_0549e0e2ef8cf6ad89a has written up how his team handles business configuration on ramo.co.il, a Next.js storefront for home and garden tools. The stated principle is that anything which shifts with a business decision belongs in the database, while code is left holding only secrets and tracking identifiers. This is a first-person description of one team's practice, not a product release or an independently verified case study, so everything below is the author's account of his own project.\n\nHe opens with a problem that will feel familiar. Near the top of a file sits a constant defining a store's free-delivery threshold; a month later that number is changed, then the fee is changed, then a holiday notice becomes necessary — and a one-line business decision has become a pull request, a review and a deployment. Drawing the line, by his rule of thumb, is simple: anything an owner or an operations person might ask whether they can change counts as a setting.\n\nUnder that rule he lists delivery fees and free-delivery thresholds, minimum order amounts, pickup options together with their notices, banners and opening hours, and contact details and shop texts. Secrets and environment-specific IDs stay in environment variables. The storage he describes is deliberately plain: a single key/value table with a key, a JSONB value and an update timestamp, with keys named by area such as delivery.fee or delivery.freeThreshold. A small admin screen edits the rows so that non-developers can make changes without touching code.\n\nStoring the values, the author makes clear, is only the easy half. The harder half, as he tells it, is reading them without a database hit on every request and without the storefront collapsing when the database has a problem. A typed loader wrapped in Next.js's unstable_cache is his answer. Every row whose key begins with delivery. is fetched, the raw JSON is turned into a typed object once, and a fallback object is returned if the read throws.\n\nThree choices are singled out in the post. Typing happens at the boundary, so the rest of the application never guesses at the shape of a value. A fallback keeps pages rendering when the read fails, and he cautions that fallbacks need care, arguing that a missing fee should fail safe rather than quietly hand out free shipping. The cache is tagged, and saving a setting calls revalidateTag so the change surfaces without a deployment.\n\nThe save path is a server action that upserts the row and then revalidates the tag. He also describes validating every setting against a schema before it is written, reasoning that once non-developers can edit values someone will eventually type text into a number field, and that the database should only hold values the code can read. He recommends keeping an audit trail of who changed what, saying it saves arguments later.\n\nHe points to a subtler bug: what the cart shows and what the server charges do not match. By his stated rule, the delivery fee is computed on the server from the same loader, and what the server returns is all the client displays — one source of truth, with no duplicated constants in components.\n\nHis description of the pattern's benefits runs as follows: business changes no longer wait for a release cycle; copy and price tweaks no longer make developers a bottleneck; logic, rather than numbers, is what code reviews focus on; and fewer hotfix deployments exist solely to change a value. These are his own assessments of his team's experience, not measured outcomes.\n\nAbout the drawbacks he is equally direct. Settings sprawl is one, and the mitigation he suggests is grouping keys by area and deleting unused ones. Cache lag is another, which means deciding how stale a value may be and revalidating on save. Testing is a third: he recommends seeding sensible defaults in local and test environments, so that tests do not depend on production data.\n\nThe post ends by inviting other developers to describe how they handle business configuration, naming a database, a CMS and feature-flag tooling as the alternatives he has in mind. The supplied material contains no responses or comparisons from other practitioners, so there is no evidence here about how widely the pattern is used or how it performs outside this one storefront.\n\nFor freelancers and developers building small commerce sites, the transferable part is less about Next.js than about where the boundary sits. The author's split, secrets and environment IDs in environment variables and anything a client might want to change in a table, is a concrete rule that can be applied on other stacks, though the caching and revalidation mechanics he describes are tied to Next.js cache primitives.\n\nEditorial interpretation: the most portable element of the account is its failure-mode reasoning rather than its code. Choosing a fallback that fails safe, computing charges server-side from the same source the display uses, and validating input before it reaches the database are decisions that outlive any particular framework. The author presents them as lessons from one project and supplies no incident data, error rates or before-and-after measurements to quantify the benefit.\n\nWhat remains unknown is substantial. The post gives no information on the size of the storefront, how many settings rows exist, how often they change, or whether the fallback path has ever been exercised in production. It also does not describe how the admin screen is secured or how the recommended audit trail is implemented. The cache helper the author imports is named unstable_cache, and the post does not discuss what that naming implies for future upgrades.\n\nThe account is best read as a documented pattern from a working developer rather than a validated methodology. Its value to this audience lies in the specific division of responsibilities it proposes and the failure cases it anticipates, which other developers can weigh against their own projects without adopting the same stack.",
  "category": "dev",
  "language": "en",
  "datePublished": "2026-11-11T07:18:57.293Z",
  "dateModified": "2026-11-11T07:18:57.293Z",
  "eventDate": null,
  "sourcePublicationDate": "2026-11-05T16:58:30.000Z",
  "source": {
    "name": "dev.to",
    "url": "https://dev.to/elias_0549e0e2ef8cf6ad89a/stop-hardcoding-delivery-fees-keeping-store-settings-in-the-database-with-nextjs-3ldg",
    "kind": "community"
  },
  "practicalImpact": "Editorial interpretation: developers building small storefronts can adopt the author's boundary rule, secrets in environment variables and client-changeable values in a table, and borrow his failure-mode reasoning (fail-safe fallbacks, server-computed charges, validation before write) even on stacks other than Next.js. The caching and revalidation specifics he describes depend on Next.js cache primitives.",
  "limitations": "This is a single developer's first-person account of one storefront, not an independently verified case study. No store size, settings volume, change frequency, error rates or before-and-after measurements are provided, and the post does not describe how the admin screen is secured or how the recommended audit trail is implemented. The cache helper the author imports is named unstable_cache, and the post does not discuss what that naming implies for future upgrades.",
  "keyPoints": [
    "The author says his team keeps delivery fees, free-delivery thresholds, minimum orders, pickup notices, banners, opening hours and shop texts in a single key/value settings table with a JSON column, while secrets stay in environment variables.",
    "Settings are read through a typed loader wrapped in Next.js unstable_cache with a fallback object, and saved through a server action that upserts the row and calls revalidateTag so changes appear without a deploy.",
    "The author recommends schema validation before writing any setting and an audit trail of who changed what, citing the risk of non-developers entering invalid values.",
    "He warns that the server should compute delivery charges from the same loader the client displays, to avoid showing one threshold and charging with another."
  ],
  "review": {
    "status": "source-reviewed",
    "checkedAt": "2026-11-11T07:18:57.293Z",
    "method": "Automated comparison against retrieved source text; not independent fact-checking.",
    "correctionNote": null
  },
  "sources": [
    {
      "id": 1,
      "url": "https://dev.to/elias_0549e0e2ef8cf6ad89a/stop-hardcoding-delivery-fees-keeping-store-settings-in-the-database-with-nextjs-3ldg",
      "publisher": "dev.to",
      "title": "Stop Hardcoding Delivery Fees: Keeping Store Settings in the Database with Next.js",
      "publishedAt": 1793897910000,
      "fetchedAt": 1794381498148,
      "hash": "837c96616586bffb52a5c990e62864954312199f24139368ffd6a976c79d0dbe",
      "kind": "community"
    }
  ],
  "claims": [
    {
      "claim": "The author states that on ramo.co.il, a Next.js store for home and garden tools, the team decided that anything changing with a business decision lives in the database, with code holding only secrets and tracking IDs.",
      "source": 1,
      "id": "claim-1",
      "url": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2#claim-1"
    },
    {
      "claim": "He lists delivery fees and free-delivery thresholds, minimum order amounts, pickup options and notices, banners and opening hours, and contact details and shop texts as settings, while secrets and environment-specific IDs stay in environment variables.",
      "source": 1,
      "id": "claim-2",
      "url": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2#claim-2"
    },
    {
      "claim": "Settings are read through a typed loader wrapped in unstable_cache that returns a fallback object if the database read fails.",
      "source": 1,
      "id": "claim-3",
      "url": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2#claim-3"
    },
    {
      "claim": "Saving a setting upserts the row and calls revalidateTag so the change appears without a deployment.",
      "source": 1,
      "id": "claim-4",
      "url": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2#claim-4"
    },
    {
      "claim": "The author recommends validating every setting with a schema before writing and keeping an audit trail of who changed what.",
      "source": 1,
      "id": "claim-5",
      "url": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2#claim-5"
    },
    {
      "claim": "He states the server computes the delivery fee from the same loader and the client only displays what the server returns, avoiding duplicated constants.",
      "source": 1,
      "id": "claim-6",
      "url": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2#claim-6"
    }
  ],
  "formats": {
    "html": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2",
    "markdown": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2.md",
    "json": "https://freelancenews.online/news/developer-describes-moving-store-business-settings-out-of-code-and-121e5ad2.json"
  }
}