Skip to content

Platform

Server-side logic.
No separate deploy.

Write JavaScript, push it with one command, and it runs inside Nimbu, next to your content, customers, and custom data. Functions, custom HTTP routes, scheduled jobs, and callbacks. No serverless account. No second auth layer.

cloud-code/pricing.js
// gate B2B pricing on the logged-in customer
$ Nimbu.Cloud.define('recalcPricing', async (req, res) => {
$ const customer = req.customer;
$ if (!customer) return res.error(401, 'auth required');
$ const price = applyGroupRules(customer, req.params);
res.success({ price }); // no separate backend

One runtime. Four shapes.

Cloud Code covers what templates cannot. Functions hold named server-side logic callable from a theme, a client, or an agent. Custom HTTP routes are your own GET/POST/PUT endpoints mounted on the site. Scheduled jobs run background work on a cron schedule. Callbacks fire before or after events on content, products, customers, and orders. The Nimbu SDK is injected into the runtime. There is no API client to configure and no credentials to pass.

  • Functions Named server-side logic, callable from a theme, API client, or agent.
  • Custom routes Your own GET/POST/PUT/PATCH/DELETE endpoints, mounted on the site.
  • Scheduled jobs Background work on a cron-style schedule, or enqueued on demand.
  • Callbacks Before/after hooks on content, product, customer, and order events.
cloud-code/archive.js
// illustrative, verify surface at docs.nimbu.io
$ Nimbu.Cloud.define('archiveArticle', async (req, res) => {
$ if (!req.customer) return res.error(401, 'auth required');
$ const a = await new Nimbu.Query('articles').get(req.params.id);
$ a.set('archived', true); await a.save();
res.success({ id: a.id, archived: true });

The tools backend work actually needs.

Cloud Code ships a curated module library so you reach for http, crypto, jwt, csv, pdf, and mail without wiring them yourself. The honest scope: this is a sandboxed V8 runtime, not full Node.js with npm. The catalog is fixed, handlers run under execution timeouts, and you cannot add arbitrary packages. That is the trade. You get a narrow surface you can reason about and deploy in seconds instead of a dependency tree you own forever.

cloud-code/sync.js
// illustrative, module names per docs.nimbu.io/docs/cloud-code/modules
$ const HTTP = require('http');
$ const jwt = require('jwt');
$ const token = jwt.sign({ sub: customer.id }, signingKey, { expiresIn: '15m' });
$ const res = await HTTP.post('https://api.partner.example/sync', {
$ headers: { authorization: `Bearer ${token}` }, body: payload,
});

Use cases

What gets built with it.

The work that used to mean standing up a separate backend service, or adding another glue layer to the portal.

  • Price recalculation and B2B rules

    Apply per-customer or group pricing server-side with request.customer context, then return trusted results to the theme or API.

  • Data enrichment and validation

    On before-callbacks for channels or customers, validate and normalize entries as they are saved.

  • Custom auth flows and gated routes

    Sign and verify JWTs, integrate an external IdP, gate functions and routes on request.customer.

  • Stateful workflows and webhooks

    React to customer, order, and content events. Expose routes, enqueue jobs, sync to ERPs and CRMs.

  • Transactional email and exports

    Send mail on events, generate CSV or PDF exports on demand, no third-party function host needed.

  • Scheduled background jobs

    Nightly sync, cache warm-up, report generation. Runs on a cron schedule with no external scheduler.

Assert behavior before it touches production.

Cloud Code is testable in isolation. @nimbu/testing runs your handlers against in-memory fixtures so you assert behavior before anything reaches a live site. It plugs into Jest, mocks the API and the request context, and hands you the registered handler to call directly. Catch the regression on your machine, not on the client's launch night.

__tests__/archiveArticle.test.js
// illustrative, verify API at @nimbu/testing README
$ const { getCloudFunctionHandler, mockRequest } = require('@nimbu/testing');
$ test('archiveArticle marks the article archived', async () => {
$ const handler = getCloudFunctionHandler('archiveArticle');
$ const result = await handler(mockRequest({ params: { id: 'abc' }, customer }));
expect(result.archived).toBe(true);

Deploy it, then run it, from the CLI or an agent.

Cloud Code does not only run when a person clicks. A function can be called from a theme, hit over the REST API, fired by a content or order event, run on a schedule, or invoked by an agent over the CLI. Because the same logic is reachable by hand, over the API, and from the command line, an agent can deploy a function and then run it on a real site. The backend is as programmable as the rest of the platform.

agent ~ nimbu deploy
# illustrative, verify against the CLI repo
$ nimbu apps push
code/ deployed. 3 functions registered.
$ nimbu functions run recalculatePricing --site demo-shop
running recalculatePricing...
done. agent operated the live site.

In practice

Backend control without the overhead.

We moved three client integrations off a separate Lambda setup into Cloud Code. One deploy pipeline dropped out of the picture entirely, and the logic sits next to the data it touches.

Senior developer, Zenjoy

Write the logic. Push it once. It runs in the platform.

No serverless account. No separate deploy. EU infrastructure, next to your data. Book a 30-minute intro or read the docs to get started.