CodelabDocs
Behavior

Action

Named store chains and code-shipped primitives that run when a Function slot fires.

An Action is a named, ordered chain of calls on a store. The same call shape also names a primitive (set-property, navigate, …) or a hook method (<hookId>.setFieldValue). You never put a sequence on an element — an event slot holds one call; multi-step lives on the store.

Bind a call on a Function slot with update_props (Props).

Store action openModal — a set-property chain on rsvp
Store action openModal — a set-property chain on rsvp

A call

NameTypeDefaultDescription
functionIdstringPrimitive slug, store action id, or "<hookId>.<method>".
instanceParamsobjectCall-site arguments. Keys match the target's param names.
when{{…}}alwaysIf falsy at dispatch, the call (and a store action's whole chain) is skipped.

functionId is one of three things:

TargetfunctionIdWhere it lives
Primitiveslug, e.g. "set-property"Built-in. Discover with list_primitive_functions.
Store actionthe action's idstores.<name>.actions[].
Hook method"<hookId>.<method>"The hook row's id, not its alias.

Unknown ids throw Unknown action id: … at dispatch.

Primitives

Client primitives run in the browser. Server primitives with public access run from the published app by reloading the owner's saved binding — see Function.

list_primitive_functions returns the live param catalog per id.

Write one store field. value may be a literal or a {{…}} expression.

ParamTypeDescription
storestringStore name.
propertystringField to write.
valueliteral or {{…}}New value.

{{event}} is the first argument the host passed — for onValueChange / onOpenChange / onCheckedChange that argument is the new value. Native onChange is usually {{event.target.value}}.

Declare every field you write, with a defaultValue. An undeclared field resolves to undefined and flips controlled inputs. A computed field (editable: false + an expression defaultValue) is derived on read; do not target it with set-property.

Other primitives

functionIdContextParamsNotes
delayclientmillisecondsWait before the next link in a store action.
browser-alertclientmessageBlocking alert().
logclientlabel, valueConsole log for wiring.
toastclienttitle, description?, type?, timeout?, id?, anchor?Repeating id replaces; anchor is an element binding.
code-actionclientcode, async?JS expression; its value becomes {{event}} for onSuccess. Reach browser APIs as {{js.navigator.clipboard.writeText(…)}}.
abort-controller-createclientstore, propertyWrites a live AbortController onto the field. After .abort() it is spent — call again.
http-requestserver, publicurl, method?, headers?, body?, responseStore?, responseProperty?Secrets as {{env.X}} resolve on the server. Result { status, data } — 2xx is success, 4xx/5xx fires onError with the same shape.
supabase-loginserver, publicemail, passwordWrites {{session.*}} (pending / user / error). Do not declare a session store.
supabase-signupserver, publicemail, passwordSame session seam.
supabase-logoutserver, public(none)Clears the session cookie.
supabase-queryserver, publictable, operation?, values?, match?, filters?, columns?, single?, maybeSingle?, order?, limit?, rangeFrom?, rangeTo?, count?, onConflict?, returning?, guestToken?, plus optional response captureRuns as the signed-in user (or anon) under RLS, only against this app's project.

Server primitives optionally capture { ok, status, data } into responseStore / responseProperty after a successful settle.

Store actions

A store holds actions. One action is a reusable chain; its functions array is the only place a sequence lives.

NameTypeDescription
idstringBind this as functionId — not the name.
namestringHuman name. Also the expression {{stores.<store>.<name>(…)}}.
functionscall listOrdered links. Each link is a call (functionId + instanceParams).
paramsfield listOptional signature. Call-site instanceParams resolve first; inner links read {{params.<name>}}.
returnstypeOptional return type.

Inside the chain, {{this.<field>}} is the owning store's live state.

The chain awaits each link. Its value is the last link's settled value. A later link may read what an earlier one wrote ({{event}}, a responseStore capture).

A synchronous value the host reads at the call site (filter, itemToStringLabel, validate) must be a single code-action whose body is not declared async: true. That callable is also reachable as {{stores.<name>.<actionName>(…)}}. Anything richer (a primitive, a multi-link chain, a body marked async) settles to a Promise.

update_store wholesale-replaces fields and actions. list_stores first (pass storeId for the full arrays), append in memory, send the whole array.

onSuccess / onError

Any primitive binding may carry reserved continuation slots in instanceParams. They are not primitive params: they are stripped before dispatch and never sent to the server.

Exactly one fires after settle:

SlotWhen
onErrorThe primitive threw, or it returned a soft failure ({ ok: false }).
onSuccessOtherwise.

Each value is a nested call (client, server, or store action). The outcome is {{event}} for the handler. Auth primitives re-read {{session.*}} after they write it, so a login's onSuccess sees the new user.

Example: supabase-login with email / password from the login store, and onSuccessnavigate to home.

Unhandled soft failure stops a store-action chain — wire onError to continue. A handler that itself fails is that handler's failure, not the original primitive's.

Expressions on a call

instanceParams values may be literals or {{…}}. A whole-binding string ("{{event}}") is stored as an expression. Nested objects and arrays resolve too. Mixed text ("Hello {{stores.user.name}}") stays a string and interpolates.

On dispatch, these namespaces are in scope:

ExpressionMeaning
{{event}}Handler argument, or the previous link / continuation's value.
{{stores.<name>.<field>}}Live store state.
{{hooks.<alias>.<key>}}Hook output (values, data, matches, …).
{{this.<field>}}Owning store, inside a store action.
{{params.<name>}}Declared action inputs, inside a store action.
{{session.*}} / {{page.*}}Ambient viewer / route. Display only — authorization is the session cookie + RLS.
{{env.X}}Server-only secrets; stay literal on the client so the server resolves them.
{{js.*}}Browser globals (clipboard, localStorage, …), event-time on the client only.
{{props.*}}Enclosing component instance props, including host callbacks.

On this page