Home
A ruleset reads nested user and cart fields
Four widgets are the outcomes of one nested ruleset. The page sends user.plan, user.lastPurchaseAt, and cart.value inside one object. It asks the ruleset four times: Pro plan, a cart of 100, a purchase on 2026-06-01, and a free plan with a small cart. Rules run in that order, and the last case uses the default.

Pro plan: Pro plan

High cart: High cart

Recent purchase: Recent purchase

Default: Default

Back

How is this widget called

This page does not pass a widget key. It passes the ruleset key four times, each time with a different params object. The server flattens that object into user.plan, cart.value, and user.lastPurchaseAt before the rules run.

Rules are first match wins. The first object has plan pro, so the Pro rule matches. The second has a free plan and a cart of 100, so the cart rule matches. The third has a purchase date in 2026 and a small cart, so the recent-purchase rule matches. The fourth has a free plan, a small cart, and no purchase date, so the ruleset uses its default.

libraries loads the source components that draw the widget. fetchOptions uses cache: "no-store" so each request reads the current widget instead of a cached copy.

The ruleset key comes from RULECMS_RULESET_KEY_NESTED_RULESET_PRODUCTION. The token is read from RULECMS_PRODUCTION_TOKEN on the server. Its value is not shown here.

TSXRead only
1<RuleCMSWidgetServer
2  token={process.env.RULECMS_PRODUCTION_TOKEN}
3  rulesetPublishedKey="b35446f1-4661-4194-af57-6ec87a7b94b7---ruleset-dc7019fc-abbb-4e7d-8075-2cc307fdfbd6"
4  params={{ user: { plan: "pro" }, cart: { value: 10 } }}
5  libraries={{
6    default: () => import("@rulecms/source-components-react"),
7  }}
8  fetchOptions={{ cache: "no-store" }}
9  errorFallback={<p>The Pro plan case could not be resolved.</p>}
10/>
11
12<RuleCMSWidgetServer
13  token={process.env.RULECMS_PRODUCTION_TOKEN}
14  rulesetPublishedKey="b35446f1-4661-4194-af57-6ec87a7b94b7---ruleset-dc7019fc-abbb-4e7d-8075-2cc307fdfbd6"
15  params={{ user: { plan: "free" }, cart: { value: 100 } }}
16  libraries={{
17    default: () => import("@rulecms/source-components-react"),
18  }}
19  fetchOptions={{ cache: "no-store" }}
20  errorFallback={<p>The high-cart case could not be resolved.</p>}
21/>
22
23<RuleCMSWidgetServer
24  token={process.env.RULECMS_PRODUCTION_TOKEN}
25  rulesetPublishedKey="b35446f1-4661-4194-af57-6ec87a7b94b7---ruleset-dc7019fc-abbb-4e7d-8075-2cc307fdfbd6"
26  params={{
27    user: { plan: "free", lastPurchaseAt: "2026-06-01T00:00:00Z" },
28    cart: { value: 10 },
29  }}
30  libraries={{
31    default: () => import("@rulecms/source-components-react"),
32  }}
33  fetchOptions={{ cache: "no-store" }}
34  errorFallback={<p>The recent-purchase case could not be resolved.</p>}
35/>
36
37<RuleCMSWidgetServer
38  token={process.env.RULECMS_PRODUCTION_TOKEN}
39  rulesetPublishedKey="b35446f1-4661-4194-af57-6ec87a7b94b7---ruleset-dc7019fc-abbb-4e7d-8075-2cc307fdfbd6"
40  params={{ user: { plan: "free" }, cart: { value: 10 } }}
41  libraries={{
42    default: () => import("@rulecms/source-components-react"),
43  }}
44  fetchOptions={{ cache: "no-store" }}
45  errorFallback={<p>The default case could not be resolved.</p>}
46/>
Pro plan: You are seeing the Pro plan widget. The page sent user.plan as pro, that rule matched first, and the ruleset chose this widget.
High cart: You are seeing the high-cart widget. The page sent cart.value of at least 100, user.plan was not pro, and the cart rule matched.
Recent purchase: You are seeing the recent-purchase widget. The page sent user.lastPurchaseAt on or after 2026-01-01, and neither the plan rule nor the cart rule matched.
Default: You are seeing the default widget. The plan was not pro, the cart was under 100, and there was no purchase date on or after 2026-01-01, so the ruleset used its default.