rudra-js
rudra-js is an open-source TypeScript library (MIT) you install from npm. A language model designs one product-recommendation block for a page in your shop, rudra-js checks it against your catalog, and React renders it.
It is not a hosted platform, a visual or low-code app builder, or a workspace you sign up for.
The five packages
@rudra-js/coredecides what goes in the block and checks it against your catalog.@rudra-js/reactrenders the block either on the server or in the browser.@rudra-js/anthropicconnects core to Claude.@rudra-js/attestedchecks the wording against the facts you supply.@rudra-js/a2uilets an A2UI agent place the block.
A block on a page
This is the page from the quick start. It doesn't need a model or an API key to show a block of recommendations.
import { createComponentGenerator, parseTrackingInput } from '@rudra-js/core';
import { RudraComponent } from '@rudra-js/react';
const catalog = [
{ sku: 'A-1', title: 'Cast iron skillet', category: 'Cookware', price: 39, currency: 'USD' },
{ sku: 'A-2', title: 'Enamel dutch oven', category: 'Cookware', price: 89, currency: 'USD' },
{ sku: 'A-3', title: 'Chef knife', category: 'Knives', price: 55, currency: 'USD' },
];
async function recommendations() {
// Passing no provider means no API key and no spend.
// Core builds the block itself, and the same input always gives the same block.
const generator = createComponentGenerator({ provider: null });
// Parsing fills in what you left out and rejects anything that doesn't belong.
// Always pass the parsed candidates to the renderer, not your raw objects.
const input = parseTrackingInput({
user: { id: 'shopper-1' },
context: { surface: 'pdp', currentSku: 'A-1', currentCategory: 'Cookware' },
candidates: catalog,
signals: { cart: [{ sku: 'A-2', at: Date.now() }] },
});
const spec = await generator.generate(input);
return <RudraComponent spec={spec} products={input.candidates} locale="en-US" />;
}
export default recommendations;See it running
The demo is a product page in a small example shop with a block of recommendations on it. It plays back a single recording of the model's answer for that page. So it calls no model and costs nothing.
If you open any other product, you get the block core builds without a model, because no answer was recorded for that page.
Where to go next
- Quick start: Put a block on a page with no API key, then turn the model on.
- How it works: The five packages, and how one page view becomes a block on the page.
- Reference: One page for each function, component and type you use.