Soba Docs

Integrate

Components

Drop-in React components for connecting compute, showing its state, picking a plan and taking payment, with a hook and a raw API underneath so you can replace any of them.

JavaScript
<SobaProvider sessionEndpoint="/api/soba/session">
  <SobaPlans />       <ComputeSettings />    <ConnectButton />
</SobaProvider>
JavaScript
const { run, plan, compute, connect } = useSoba();

Three levels: component, hook, raw API. You can replace any one of them without leaving Soba, which is the point of shipping all three.

<SobaProvider>#

Wraps the tree and carries the one thing everything else needs: a session for the signed-in user. A browser cannot mint one, because that takes your secret key, so sessionEndpoint is a route of yours that mints it the way Sending someone to the approval page does and returns { session, expires_in }. The provider calls it with the user's cookies and calls it again before the session runs out. The id your route puts in it is what attributes a run to a person and decides whose machine it may reach.

Where to mount it, and what it costs#

A mounted provider is not free. It mints a session, reads your app's connect settings, and keeps the user's machines current. So mount it on the pages that show compute or plans, or only once a run has failed with no_compute or payment_required. Do not mount it in the root layout of every page.

The one exception is the header, in an app whose AI only works once a user connects their own compute — a bring-your-own plan, a route that only allows their machine or subscription. There <ConnectButton /> belongs in your signed-in navbar, on every page a signed-in user sees, so its provider goes in the layout that draws that navbar — not in a root layout that also renders your login and marketing pages, where there is nobody to mint a session for. Pass sessionCacheKey and the header's session is reused across navigations, reloads and tabs, and shared with any provider a page mounts.

What it does while mounted is already as little as it can be:

  • Machines are polled only while someone is using a visible tab. A hidden tab makes no requests, the poll catches up the moment the tab is back, and it slows to once every few minutes when nobody has touched the page for a while.
  • Plans are fetched only once something on the page reads them, such as <SobaPlans />, useRunLimit or useSoba().plan. A page with only a connect button never asks.
  • One session per page. Two providers on the same screen, such as a bar in the header and a panel below it, share one session.
  • One session per person, across reloads and tabs, when you pass sessionCacheKey: the signed-in person's id in your app. The session is kept until it is about to expire, so a reload or a second tab asks your server for nothing. Use their id, never a constant: a session acts as the person it was minted for.

initialMachines, initialConnect and initialPlans skip the first read when you already have the data. Never add a server read on every render just to fill them, least of all in a layout. The provider makes the same read itself on mount, so the server call only buys one loading frame. And it adds a request to Soba to every full load, refresh and revalidating action of every page.

If your site sets a Content Security Policy#

The provider reads the user's machines from Soba's gateway, https://api.soba.so, and everything else from https://soba.so. Allow both in connect-src:

Content-Security-Policy: connect-src 'self' https://soba.so https://api.soba.so

If api.soba.so is blocked, the panel still works: it reads the machines from soba.so and tries the gateway again every few minutes, which leaves a blocked request in the console each time.

<ComputeSettings />#

The compute section of a settings page, drawn as rows of that page in its own type and colour: each machine with what it is, which agent your runs go to there, and whether it is awake, asleep or serving; Connect compute when there is nothing and Connect another computer when there is. Its buttons raise the pairing modal directly.

Mount it alone. <ConnectButton /> is the header's control (once something is connected it becomes a pill that opens a popover), and <ComputeStatus /> is that popover's machine card, so either one beside this draws the same machine twice.

<ConnectCompute /> is its older name. It renders <ComputeSettings />, except with showStatus={false}, where it is still the control alone.

The connect step behind it is the one that carries the real friction. There are two flows behind one button, and which one a user meets depends on their provider and platform:

ChatGPT An OAuth popup. No install
Claude Install Soba, paste the connect link, approve the code in the browser, paired. It stays running as a login item

Neither ever displays or asks for a pasted credential. See Pairing.

For someone who has already paired, this is not a connect step at all: the section lists the machines they have and keeps Connect another computer one click away. Someone arriving the second time came to check something, not to be sold the idea again.

<ComputeStatus />#

The machine card from the header's popover, for a surface of your own that wants it outside a settings page. The component with no equivalent in an auth product, and the one that matters most: when the compute is the user's own machine, the state of that machine is user-facing. Asleep, offline, signed out of its CLI, or serving a run right now are all things the person needs to be able to see, because they are the only one who can do anything about them.

<ModelPicker />#

Which model answers, as one pill that goes beside your send button.

JavaScript
const { run } = useSoba();
const model = useModel();

<ModelPicker />
<button onClick={() => run({ prompt, ...model.run })}>Send</button>

The list is read off what the person connected, not configured anywhere. Claude Code advertises haiku, sonnet, opus and fable because those are the words its CLI accepts; a local endpoint advertises whatever has been pulled; Codex advertises none and gets Automatic alone. You cannot know any of that at build time, which is why this is derived rather than a constant in your app — and why it changes on its own when somebody connects a second agent, with no event for you to subscribe to.

Three options sit above the names:

Automatic The machine's own default. It says which agent that is
Fast / Best small and large — the quick model and the most capable one, resolved against whichever agent serves

Fast and Best are the two that survive a change of agent. A pinned Opus means nothing on somebody who has swapped their laptop for one running Codex; a size still does. They are offered only where a connected agent actually maps them, so Codex — which maps neither, and would quietly run its default — is not offered a row that does nothing.

Spread model.run, do not read model off it. For a named model it is { model, runtime } and the pair has to travel together: Soba applies the person's preferred agent only to a run whose model is blank or a size, so opus sent on its own is handed to whichever agent is found first. Forwarding only model works until somebody with two agents picks from the second one.

It draws nothing when there is nothing to pick, which is every app on its first day: before anybody pairs a machine the only option is Automatic, and a menu with one row in it is a label that looks pressable. <ConnectNudge /> is the component whose job is that case.

Setting it from code, or from an agent#

Everything on the dashboard's Model Picker card can be set without it. In code, a prop wins over the dashboard for that picker and the runs it sends:

JavaScript
<ModelPicker layout="tabs" rows={{ fast: false, search: false }} />
Card Prop
Users choose a model layout="automatic" is off: no picker, every run on Automatic
Menu layout: providers (Submenus), panes (Two panes), tabs, list
Suggested rows={{ suggested: false }} hides the group (every preset off)
Presets rows={{ auto, fast, best }}
Labels rows={{ labels: false }}: Two panes and Tabs show logos alone, the name on hover. Submenus always names them
Search rows={{ search }}
Effort rows={{ effort: false }} hides it; rows={{ effortStyle: "switch" }} or "list". Submenus always lists it beside the models

Pass the same props to every useModel() call, as with choices. Left out, each follows the dashboard.

An agent sets the card itself with the soba_set_model_picker tool in the Soba MCP server, or PATCH /v1/manage/app with { "model_picker": { "users_choose": true, "menu": "tabs", "presets": { "fast": false }, "search": true, "effort": true, "effort_style": "list", "labels": false, "suggested": true } }. From a terminal, soba settings set model_picker.effort_style=list model_picker.labels=false. Send only what changes; the answer is the card's whole state.

Users' own AI can be turned off for the whole app: own_ai: [] in PATCH /v1/manage/settings (or soba settings set own_ai=[]). The connect popup then offers nothing to connect, and no run reaches a user's own subscription, machine or key. null brings back the default AIs.

Effort shows only for models whose AI takes it (Claude Code and Codex). The level picked rides on the run: useModel().run carries effort, or pass effort: "high" to soba.run() yourself.

When the machine with their model on it is asleep#

The pick is kept and the run still goes. selected falls back to Automatic, unavailable carries what they chose, and the moment the machine is back so is their model — the same thing Soba does with a preferred agent that has gone away. Say something with unavailable if you have the room; ignoring it is also correct, because the run works either way.

The pick is remembered in the browser, scoped to your app and — if you pass user — to the person. Pass value and onChange instead and it is yours: nothing is stored, and the picker reads the value you hold.

Call useModel() as many times as you like. The pick is not held by the control — the snippet above is two call sites, and they always agree, including across two tabs. Picking in the pill and sending the model you picked is the whole job, and a control that moved while the next send carried something else would be the one way this can go quietly wrong.

Where to put these#

<ComputeSettings /> on a settings page is the obvious placement and the weakest one. A settings page is where somebody goes to check on a machine they already connected. It is not where they decide to connect one, because nobody visits it wondering whether to.

The decision happens at three other moments, and all three are the same modal opened from three places:

Moment What goes there
A run just failed for a reason they can fix <RunLimit />, in the place the answer was going to be
They are weighing what to pay The connect row <SobaPlans /> draws from the plan's reward — as a line on every card, and as a button on <SobaCurrentPlan />, which is the half that knows whether anything is attached
Every control that starts a run <ConnectNudge predict error={error} />, directly above it — a Tidy or Summarise button as much as a chat composer — speaking before the press when nothing can serve, and after a refused one
Every signed-in page, when nothing runs until they connect <ConnectButton /> in the navbar, and only there
The allowance is running low <ConnectNudge />, quietly, while they still have a choice

<ConnectButton /> is outlined and marked by default. It hands somebody to a flow that is not yours — nine steps, a download, a sheet with our name at the foot — and drawn as a filled black control it was the loudest thing on whatever settings page it landed on. variant="primary" is one prop away for a page whose whole purpose is this. Pass children and it says what you told it to, mark and all dropped: stamping a logo on your words would be the component talking over you.

The flow behind all of them is nine steps long and involves a download, so none of these tries to be the flow. A card is a trigger; the modal is the flow. <SobaProvider> mounts exactly one modal and connect.open() raises it, so an app with all three cannot put two pairings on screen at once.

<RunLimit />#

The two failures a person can do something about, and the offer that answers each. Pass whatever your catch block caught:

JavaScript
<RunLimit error={error} onDismiss={() => setError(null)} />

It renders nothing unless the error is a 402, the plan's allowance is spent, or a 409, nothing this run may use is connected and awake. So it can sit permanently in your tree, and an unrelated error still renders however your app renders errors.

variant="card" sits in the flow of the page, where the failed run is, drawn in the grammar every agent surface already uses to ask "may I run this": a mark, the question, the consequence, and the answers on the right with the affirmative last. In a stream of messages a card with no mark reads as something the assistant said; this is something the app is asking. variant="dialog" covers the page with the same content. Same content either way: the container is the only difference, which is why a card or a modal is one decision and not two components.

It tells four situations apart, because they want four different sentences:

Allowance spent, plan rewards connecting, nothing connected Connect, primary. Upgrading second
Allowance spent, already connected Upgrade only. Connecting again would change nothing, and offering it would be untrue
Nothing connected at all Connect
Connected but unreachable Names the machine. Open Soba is the fix and takes the primary; pairing another one is the way round, and sits beside it

A plan whose reward is credit is never offered as the way past a wall: a credit is assessed at renewal, which is true and no use to somebody standing at one right now.

Before a run, not only after#

Omit error, or pass predict alongside it, and the card watches the state as well, appearing before a run is attempted:

JavaScript
<RunLimit error={error} predict onDismiss={() => setHidden(true)} />

This is the form a chat wants. A plan that can only reach compute the user owns, with nothing connected, has nowhere to send a message, and saying so in the stream above the composer beats saying it in the wreckage of a request.

A button wants the other one. <RunLimit error={error} /> with no predict waits for a failure, because there the press is the attempt: a card saying "nothing connected" under a button nobody has touched is an answer to a question nobody asked. examples/inbox has both — the chat predicts, the triage button does not, and the triage button raises its offer as a dialog because the person is now waiting on nothing.

error={null} is not a request to predict. It is the value every app holds before the first failure, and it renders nothing; only omitting the prop, or passing predict, asks for the state form.

The state form is deliberately conservative. It reports only what the plan declares about itself, its route_allow and its overage, and never reimplements the dispatch rule. Predicting a refusal is how a browser starts disagreeing with the server about whose turn it is to say no.

It reads whether a machine can serve now, not whether one was ever paired — the same fact dispatch checks first. On a plan that can only reach compute the user owns, a laptop that has stopped answering is a 409 waiting to happen, and saying so before somebody types a paragraph is the whole point of the form.

useRunLimit()#

<RunLimit /> is a thin renderer over this, and this is the one to reach for when your app has its own card grammar:

JavaScript
const limit = useRunLimit(error) // add { predict: true } to answer before a run too
if (!limit) return null
return (
  <div className="your-card">
    <strong>{limit.title}</strong>
    <p>{limit.body}</p>
    <button onClick={limit.connect}>Connect compute</button>
    {limit.upgradeTo && <button onClick={limit.upgrade}>{limit.upgradeTo.name}</button>}
  </div>
)

It returns reason, title, body, connectOffer (what connecting earns, from the plan, or null), upgradeTo (the cheapest plan that would lift this), connect() and upgrade(). The card is yours; the modal connect() raises is ours. examples/inbox uses it without rendering anything from it: the triage button asks what is already in the way, and raises the dialog instead of sending a request it knows will be refused.

sobaErrorCode(caught) is exported alongside it. It reads the code out of the error envelope, a Response, or an Error carrying either, so you never have to match on message text that will change.

Your run route has to forward the status. The failure is only answerable if the code survives the trip: return the platform's { error: { message, code } } at the status it came with, rather than flattening it into a sentence.

<RunError />#

The other half of a run that did not work, and the pair is the whole integration:

JavaScript
<RunLimit error={failure} />
<RunError error={failure} />

<RunLimit /> answers the two failures a person can act on — payment_required and no_compute, both decided before a run starts, where "connect something" or "upgrade" is a real button. This answers everything else: a supplier that refused, a key with no credit left, a model that is gone, a machine that disconnected mid-answer. They never both speak, so between them every failed run says something and neither needs you to classify anything.

It exists because that half used to be homework. useRunLimit() returns null for anything unanswerable, which is correct and is also an instruction to go and render something yourself — so every surface in this repo wrote its own, four times, and the one with the most machinery dropped the message on the floor for a month without anybody noticing.

error is required here, unlike on <RunLimit />, and deliberately: a limit can be foreseen from the plan before anybody presses anything, and an error cannot be foreseen at all. A component that drew one speculatively would be inventing a failure.

Headless: runErrorMessage(error) is the same rule as a plain function — there is no state in it, so there is nothing for a hook to hold.

JavaScript
{runErrorMessage(e) && <MyError>{runErrorMessage(e)}</MyError>}

Null means either nothing failed or <RunLimit /> has it, and in both cases the right thing to render is nothing. It matches on the code and never on the message text: a message is prose we rewrite, and an app pattern-matching our prose breaks on a copy edit.

<ConnectNudge />#

The same offer, earlier and much quieter:

2 messages left this month. Unlimited messages on your own AI. [Connect]

A wall converts because the person has no choice, which is also what makes it a poor introduction. This is the version that arrives while they still have one.

It says nothing at all unless connecting would help, nothing is connected yet, and the paid allowance is actually running out. Connecting helps on any plan that runs on their own AI, since those runs never spend the paid allowance, and on one whose reward is included. A nudge that appears when it cannot help is an advertisement. at sets how little has to be left, as a fraction of the allowance, so it means the same on a plan of 20 and a plan of 2,000.

When the run, not the plan, is what needs the machine#

The rules above read the plan, which is the right source for an app that posts a run and lets the plan decide where it may land. A surface that narrows route.allow per run — because the agent has to have the user's own files in front of it — is a different claim, and the plan is no evidence of it: on a paid, unmetered plan nothing in plan says the run could only ever have gone to hardware this person owns. Tell it:

JavaScript
<ConnectNudge
  error={err}
  allow={["user-hardware", "user-subscription"]}
  fallback={<p className="error">{message}</p>}
/>

allow takes the same value you send on the run. It changes what the card says, never where a run may go — the gateway owns that — so a value that disagrees with the run costs a wrong sentence and nothing else. An explicit null is no ceiling; undefined is "not asked" and falls back to the plan, so passing a variable that happens to be empty cannot silence the card.

fallback is what to draw when the card has nothing to offer, and it is what makes error={err} safe to put in place of your error line rather than above it. This renders nothing for a failure connecting cannot fix, nothing while the plan is still loading, and nothing when the machine came back between the run failing and the card rendering. Hand it the line you would have drawn and the failure is never swallowed: the card speaks when it can, your app speaks when it cannot.

And one thing it says that is not an offer#

Andrea's MacBook can't be reached. The Soba app there has stopped reporting in, so runs have nowhere to go until it is back. [Open Soba]

A machine that is paired and not answering — a shut lid, a dropped connection, a worker still retrying — is the one state this component reports rather than sells. So it ignores every rule above it: both integrations draw it, whether or not anything has failed, and whatever the plan rewards. An offer nobody asked for is an advertisement; this is the app telling somebody that hardware they own has gone quiet, and it withdraws by itself on the poll after the machine comes back.

The button opens the desktop app — soba://show, which asks for the window and carries nothing else — and lands on the screen that says the same sentence with Reconnect now on it. A browser cannot find out whether that worked, only whether something took the foreground, so a press that appears to do nothing says so and offers Connect another machine instead: the machine that went quiet is very often not the computer this browser is on.

Making them look like your app#

Every component is styled from custom properties on .soba-connect, and they are a supported surface rather than an implementation detail:

css
.soba-connect {
  --sc-font: inherit;      /* take the host page's typeface */
  --sc-accent: #2d6cdf;    /* the primary button and focus ring */
  --sc-accent-fg: #ffffff;
  --sc-ground: #ffffff;
  --sc-sheet: #ffffff;     /* cards and the modal sheet */
  --sc-raised: #f6f6f7;    /* the nudge, hovers, code blocks */
  --sc-line: #e9e9eb;
  --sc-line-2: #dcdce0;    /* borders that carry a control */
  --sc-text: #1a1a1c;
  --sc-text-2: #3f3f46;
  --sc-muted: #6b6b73;
  --sc-ok: #22a06b;        /* connected, and the lines that cost nobody */
  --sc-warn: #b06f14;
  --sc-r: 10px;            /* the corner radius */
  --sc-mono: "Berkeley Mono", ui-monospace, monospace;
}

--sc-font defaults to Inter, which is right for the hosted page and the desktop window because those are ours. Set it to inherit for a component sitting inside your own chat: insisting on its own typeface there is the loudest way of announcing where it came from.

injectStyles={false} on the provider turns the stylesheet off entirely if you would rather ship your own.

The connect pill#

<ConnectButton /> sits in your header, outside .soba-connect, so it has tokens of its own. Soba never sets them, so they work from anywhere above the button or on it: :root, a class, or a Tailwind [--sc-pill-bg:#fff]. A Tailwind colour or radius class on className will not work, because the kit's stylesheet is unlayered and beats utilities. Use the tokens.

css
:root {
  --sc-pill-radius: 16px;
  --sc-pill-bg: #ffffff;
  --sc-pill-bg-hover: #f1eefe;
  --sc-pill-line: #e4e1f5;      /* and --sc-pill-line-hover */
  --sc-pill-text: #1f1b3a;
  --sc-pill-muted: #6a6688;     /* the machine name */
  --sc-pill-font: inherit;
  --sc-pill-size: 15px;
  --sc-pill-weight: 700;
  --sc-pill-shadow: none;
  --sc-pill-tile-bg: #ece8ff;   /* the disc behind the mark */
  --sc-pill-tile-line: transparent;
  --sc-pill-tile-radius: 10px;
  --sc-pill-mark: #6a4df4;      /* the mark */
}

The "Connect compute" button reads the same tokens, so the control does not change when somebody pairs. The status dot uses --sc-ok and --sc-warn.

For a shape tokens cannot reach, pass a function and draw the control yourself. The button it renders in has your className and none of ours, and pressing it still opens the panel, or the pairing flow when nothing is paired:

JavaScript
<ConnectButton className="streak-chip">
  {({ loading, connected, word, tone, machineName }) =>
    loading ? null : connected ? (
      <>
        <i className={`light ${tone}`} /> {word} on {machineName}
      </>
    ) : (
      "Use your own AI"
    )
  }
</ConnectButton>

loading is true until the first read answers. Do not draw "connect" while it is, or everybody with a paired machine sees that on every refresh.

<SobaPlans /> and <SobaCheckout />#

Render the plans you configured, take the payment through your own Stripe account, and grant the entitlement. Prices, allowances and the connected reward all come from the plan objects, so a pricing change is not a deploy.

The reward is drawn as a row with a button, above the compute lines, because it is the reason to read them and because a pricing page is exactly where somebody decides to connect a machine. Sending them to a settings page to act on a decision they have just made is how the decision gets lost.

The row appears for two reasons, and reading only the first is how the most important card on a pricing page ends up with nothing to press:

  1. The plan rewards connecting. The sentence comes from the plan's connectedReward, so a pricing change is not a deploy. A credit is shown but never given a button: it is settled at renewal, so there is nothing to press today.
  2. The plan requires it. A "Bring your own" plan, free and unlimited on nothing but compute the user owns, carries connectedReward: none and is right to. There is no bonus for connecting, because connecting is the plan. Judged on the reward alone such a card offers no way to attach a machine, and everyone on it meets no_compute on their first run.

On the second, the control is primary when the plan is already theirs and nothing is connected, because then it is the only thing on the card that does anything. The requirement stops being mentioned once a machine is attached: <ComputeStatus /> is where the state of that machine belongs.

That control is off by default, and showConnect turns it on. A card in a price list answers one question — what is this plan, and how do I get on it — and on the plan somebody already holds the answer is "Your plan". Put Connect compute in that slot instead and the one card that is not a choice carries the loudest control on the page, having dropped the only label that said which plan is theirs.

Connecting is a fact about the plan they hold, not about the catalogue, so the offer belongs on <SobaCurrentPlan /> — and <SobaBilling /> is that card above this grid, which is the billing page you probably want:

JavaScript
<SobaBilling />                  {/* the card, then the grid */}
<SobaPlans showConnect />        {/* a pricing page with no card on it */}

Pass showConnect only for the second: a page where no current-plan card exists, and a Bring-your-own plan would otherwise state a requirement with no way to meet it.

The connect line is unaffected either way. "10,000 runs a month when you connect your own AI" is part of what the plan is, and somebody comparing plans should read it on every card whether or not the button is there.

Three shapes, one set of facts#

variant decides the reading order, never the content — every layout draws the same plan objects:

cards (default) A choice being made. Each plan whole and side by side, for a pricing page or an upgrade screen
rows A choice being reviewed. One line per plan with the price and the control on the right, the way a settings page lists anything you can switch between — and the shape that survives a column too narrow for a grid
table A choice being argued. Facts down and plans across, so two plans can be compared on the dimension that separates them, which here is the compute row far more often than the price
JavaScript
<SobaPlans variant="table" featured="plan_pro" />

featured names the plan you are pushing, by id, and it is drawn with emphasis in all three. A prop rather than something derived: nothing on a plan says "recommended", and inventing the claim from the price would be this component making a business decision on your behalf. A plan somebody is already on is never featured — Current is the more useful of the two things to say.

The table scrolls sideways rather than wrapping when the column is too narrow, because a wrapped comparison is not a comparison. Nothing here uses a media query: these render inside your column, and the viewport is not your column.

<SobaCurrentPlan />#

The other half of a billing page: what they are on, and what happens next.

JavaScript
<SobaCurrentPlan />

The plan's name, a trial clock when there is one, and a usage panel beside it. The arithmetic is the part apps get wrong, because it lives across two objects and four fields that disagree about what zero means:

included_units: null No ceiling, so no bar — a progress bar against infinity implies a limit
overage: "meter", past the allowance A bill, not a wall. Saying "spent" here costs you the sale
overage: "stop", past the allowance A wall, and the only useful thing to say about one is the date it lifts
connectedReward: included, machine attached The ceiling rises to connectedIncludedUnits, and the card says where the bigger number came from
Machine attached The ceiling does not move; runs their own AI serves count against own_included_units, never this one

Those last two mirror allowanceFor rather than approximating it, so the card and the run agree about what is left. A trial outranks all of them in the status line: an allowance that resets on the 12th means nothing to somebody whose trial ends on the 4th.

The connect offer, on the card that reports the state#

Beside the plan's name it draws the same connect line the pricing cards do, in the same grammar — a tick for a reward, a warn mark for a requirement nothing has met — plus the button, while connecting would still change something. This is the one surface that can say whether the reward is in force, because it is the only one that knows what is attached.

That makes it the home for the offer on a billing page, and the reason the grid under it draws Your plan on the card that is already theirs: the offer belongs beside the state it changes, and it should appear once.

heading="" drops the section title for an app that has already titled the card it is putting this in, and showUsage={false} leaves only the plan.

<SobaBilling />#

Both halves, in the order somebody reads a billing page: what they are on, then what else there is.

JavaScript
<SobaBilling />

It is <SobaCurrentPlan /> over <SobaPlans /> with one decision already made — the connect offer sits on the card that reports the state it changes, and the grid below keeps Your plan on the plan already theirs. Assembled by hand that is the thing to get wrong: both components decide from the same rule, so both draw the button, and nothing errors to say the page is asking twice.

The grid's heading follows the reader: Change plan for somebody on one, Choose a plan for somebody on none. plansHeading overrides it, heading retitles the card above, "" drops either, and showUsage={false} leaves only the plan on the card. Everything else — variant, featured, showCompute, onSelect, successUrl, cancelUrl — is passed through to the grid, because a billing page's grid is the same grid:

JavaScript
<SobaBilling variant="rows" plansHeading="Switch plan" />

variant="rows" is the pairing rows were written for: the card names the plan, and the list under it is the switch — the shape of a settings page rather than of a pitch.

Headless#

Every component on this page is one rendering of a hook, and every one of those hooks is exported. They are there for the surface you have decided to own, and for decisions no component draws — not as the default way to put Soba in a product that has its own design.

The components render exactly these values and derive nothing of their own, so what you build from a hook and what we draw cannot disagree.

Mount the component, even inside a product that has its own design. The components read what you set in the dashboard — the model picker's layout, which of Automatic, Fast and Best are offered, search, the connect popup's look — and a surface rebuilt from a hook reads none of it, so those settings stop reaching your screen. Each component takes a className for placement, and theme on <SobaProvider> sets light or dark. This is also the rule the skill follows when an agent does the integration for you.

Take a hook when you mean to own that surface, or for a decision no component draws. Then render everything it returns: useModel() is a menu with choices and their descriptions, agents and their logos, and layout and search honoured, not a <select> of names.

Component Hook What the hook decides
<SobaPlans /> usePlans() The catalogue as decisions: price, allowance, compute, the connect row, and one take() per plan
<SobaCurrentPlan /> useCurrentPlan() The allowance arithmetic and the one sentence that is true of it
<RunLimit /> useRunLimit() The two failures a person can act on, and the offer that answers each
<ConnectNudge /> useConnectNudge() Whether there is anything worth saying at all, which of four reasons, and how big it should be
<ModelPicker /> useModel() Which models this person could be answered by, the one in force, and the two fields to put on the run
<ComputeSettings /> useCompute() The settings section: each machine as a row, and the one control that adds another
<ComputeStatus /> useCompute() The machines in words, and the difference between "nothing connected" and "we have not looked yet"
<ConnectButton /> useConnectButton() What the control says once something is attached, and what pressing it means
<SobaCheckout /> useCheckout() The session, the label, and the rule that nothing is granted here
<RunError /> runErrorMessage() What to say about a failure, or null when it is not this component's to say
— tierLabel() Which of the five economics served a run, in words

Three of the components are compositions and have no rule of their own: <ConnectCompute /> is the older name of <ComputeSettings />, <SobaBilling /> is <SobaCurrentPlan /> plus <SobaPlans />, and <ConnectModal /> is the flow connect.open() raises. Build those from the hooks above and useSoba().connect.

There is one more that belongs to no component: useOpenSobaConnect(), which brings the Soba app forward and tells you the one honest thing a page can say about having tried.

usePlans()#

JavaScript
const { offers, failed } = usePlans({ featured: "plan_pro" });

offers.map((o) => (
  <YourCard key={o.plan.id} highlighted={o.featured}>
    <YourPrice>{o.price.amount}{o.price.interval && `/${o.price.interval}`}</YourPrice>
    <YourFigure note={o.allowanceNote}>{o.allowance}</YourFigure>
    {o.connect && <YourNote onAct={o.connect.actionable ? o.connect.open : undefined}>
      {o.connect.line}
    </YourNote>}
    <YourButton disabled={o.cta.disabled} onClick={o.cta.take}>{o.cta.label}</YourButton>
  </YourCard>
));

Five things every app that drew its own pricing page got wrong at least one of, and all five are decided here:

  • Free is selected, priced is checked out. select answers 402 for anything with a price, so calling the wrong one is an error either way. cta.take() picks.
  • The connect row has two reasons — a plan that rewards connecting and a plan that requires it. The second carries connectedReward: none and is invisible to anyone reading the reward alone.
  • A credit is never a button. connect.actionable is false for it: it settles at renewal, so there is nothing to press today.
  • Which control is loud. connect.primary is true only on a plan that is already theirs with nothing connected, where it is the only control that does anything.
  • Who pays for the compute. compute[].owned is the whole argument of the product as a boolean.

useCurrentPlan()#

JavaScript
const { state, percent, summary, trialDaysLeft } = useCurrentPlan();

state is none, trial, unlimited, within, metered or spent, and summary is the sentence that goes with it. The ceiling, raised and uncounted mirror allowanceFor — the rule the gateway actually enforces — so your card and the run it describes cannot disagree about what is left.

reward is the connected reward as a state rather than an offer — whether it is inForce, whether it is a required prerequisite this plan has not met, and actionable with an open() when connecting would still change something. That last pair is what stops a "bring your own" plan from reporting that nothing is connected and giving the person no way to fix it.

features is the plan's features, id to value, as this person bought them: features.projects, features.export. Everything else on this hook is what Soba enforces; these your app enforces, and nothing in Soba stops a run on them.

useModel()#

JavaScript
const { options, groups, selected, select, run, unavailable } = useModel();

options is every model this person could be answered by, Automatic first; groups is the same list arranged for a menu — Automatic and the sizes, then one group per agent. run is the one to put on the request, and it is { model } for Automatic and a size and { model, runtime } for a named model, for the reason <ModelPicker /> gives.

options[].costClass says who pays for a run served there, so a picker that wants to can mark the models running on the person's own hardware as the free ones. pickable is false when Automatic is the only option, which is when the component we draw renders nothing.

The pick is one value, not one per call site. The shape above is two calls — <ModelPicker /> for the control, useModel() wherever the send happens — and they read the same pick, so choosing Opus in the pill changes what the next send carries. That holds for defaultValue too: pass it to either one and both take it, a remembered pick outranks it, and if two call sites pass different ones the first wins. value and onChange opt out of all of it — then your app holds the pick, and it should hold it in one place for the same reason.

useConnectNudge()#

JavaScript
const nudge = useConnectNudge();

nudge.visible && (
  <YourLine onAct={nudge.open} onClose={nudge.dismissible ? nudge.dismiss : undefined}>
    <strong>{nudge.title}</strong> {nudge.detail}
  </YourLine>
);

reason is needed, running, preferred or stalled, and null is the answer most of the time — which is the whole component. A nudge that shows up when it cannot help is an advertisement, so four things are decided here that an app re-deriving them from plan and compute gets wrong:

  • A credit is not an allowance. connected_reward: "credit" settles at renewal and changes nothing today, so it never raises the running claim. Reading the reward alone cannot tell.
  • Paired is not reachable. stalled is a machine they already have that has stopped answering, and it speaks in both integrations: an app that chose the quiet one chose it about being sold to, not about being told its laptop went away.
  • ask_to_connect is the app's own switch, and only over preferred — the one claim that is an offer rather than a fact.
  • atTheWall is how big it should be. Somebody with three runs left has a heads-up; somebody at zero is stopped and the steps are the way out.

dismissible is true on preferred alone, because the other three withdraw by themselves when the fact behind them changes and that one is true for as long as everything works. steps is the download/connect/allow list if you want to draw it, and stalled carries wake(), what the attempt looked like, and whether twenty seconds have passed without the machine coming back.

The rule is also a pure function — nudgeSays(input) — if you would rather feed it facts you already have than mount a hook.

useCompute()#

JavaScript
const { view, machines, primary, stalled } = useCompute();

view is loading, error, empty or machines, and it exists because "nothing connected yet" is a claim about somebody's account that is only true once the account has been read. Saying it while the first poll is in flight tells a person with a paired laptop that it has vanished, during an outage they cannot see and did not cause. Machines already in hand beat both flags, so a poll that fails on its fourth round does not blank a list somebody is reading.

Each entry is the machine plus the words for it: name (what they called it, else a tidied hostname — not MacBook-M1-Pro.local), state for a dot, status for a sentence, hardware, lastSeen, and runtimes whose auth is tri-state — ok, warn, unknown — because rendering "could not tell" as "signed out" tells somebody their working setup is broken.

useConnectButton()#

JavaScript
const { label, ariaLabel, state, open } = useConnectButton();

A button that still says "Connect compute" after they have connected is the screen telling them it did not work, so label is a function of what is attached. ariaLabel is not the label: on a narrow bar a host hides the words and leaves a mark and a dot, and a control whose whole accessible name was those words then has none.

useCheckout()#

JavaScript
const { label, busy, error, buy } = useCheckout({ plan });

It creates a Checkout Session and navigates. It grants nothing — the entitlement is written by Stripe's webhook when the money actually moves — and that split is the whole security model: a hand-rolled version that granted the plan on redirect would hand one to anybody who could reach the URL and close the tab. session() returns the URL instead, for a native wrapper or a new tab.

useOpenSobaConnect()#

JavaScript
const { open, launch, note } = useOpenSobaConnect();

No browser will tell a page whether a scheme handler exists; the only observable consequence of one is that something else takes the foreground. So a press can be followed by nothing happening, and note is the one honest line about that — never "you do not have the app", which on a machine that is not this one would be plainly false. launch is opened, absent or unknown, and unknown says nothing at all, because the tab was already in the background and the signal means nothing.

tierLabel()#

JavaScript
const { tier } = facts;                 // from the run's first `status` event
<p>ran on {tierLabel(tier)}</p>         // "ran on your own local model"

A plain function, because there is no state in it. status carries the cost class before any output, which is why every surface that shows a run shows this: a run that quietly fell back from somebody's laptop to metered supply says so on the screen rather than in a bill.

It returns a bare noun phrase, so the sentence stays yours — "running on …" while it is, "ran on …" afterwards, or the words alone beside an icon. null for a run that has not said yet, which is what every page holds before the first event, so {tierLabel(tier)} needs no guard.

Worth importing rather than writing, for a boring reason: there were four hand-written copies of this map in our own examples and they disagreed with each other, and three of them were if-chains ending in frontier — so somebody running on their own API key was told the app had bought them frontier supply. The five classes are the vocabulary this whole product is about; they should not depend on which file you are in.

Not React#

There is a hosted fallback page, the trick Stripe Checkout uses: redirect to it, the user connects or pays there, and they come back. That covers Vue, Svelte, Rails, Django and everything else, without Soba shipping a component library per framework.

Underneath#

JavaScript
const { run, plan, compute, connect } = useSoba();
run Start a run and consume its events
plan The user's current plan, allowance and usage
compute What this user has connected, and its live state
connect Start the connect flow yourself

And under the hook, the same endpoint and /v1/runs your server already calls.

Privacy · Terms · DPA · © 2026 Soba resolved = machine grant ∩ broker request