Code and SDKs
Use the client SDK in your app's code
Read and write data, sign people in, upload files and call server functions from your app's browser code with @ahamo/client.
Every app Ahamo builds talks to its backend through @ahamo/client, with React hooks from @ahamo/react (or
@ahamo/react-native for mobile). This page is for developers reading or changing that code. The build AI already
uses it; you don't need to set anything up.
When to use it
- You edit the generated code by hand, in Code or in your own editor through GitHub sync.
- You want to know what a generated screen does with data.
How to use it
The app creates one client and provides it to React:
// Browser code. Holds no secrets.
const client = createAhamoClient({ transport: createAhamoTransport({ baseUrl }) })
<AhamoProvider client={client}>
<App />
</AhamoProvider>Then screens use hooks:
const { data: bookings } = useAhaQuery((db) => db.table('bookings').list({ where: { status: 'open' } }))
const { signIn, signOut, actor } = useAhaAuth()| Area | What it does | Main calls |
|---|---|---|
| Data | Read and change rows, subscribe to changes | db.table(name).list, get, create, update, delete, upsert, count, subscribe |
| Sign-in | Accounts and sessions | signUp, signIn, signOut, currentActor, requestPasswordReset, requestSignInLink |
| Files | Upload and link files | storage.upload(kind, file), url, remove |
| Server functions | Run trusted code | functions.call(name, input), functions.stream |
| React | Hooks around the above | useAhaQuery, useAhaMutation, useAhaAuth, useAhaFunction, useAhaFunctionStream |
Browser code never holds secrets. Anything that needs a key or a trusted check belongs in a server function.
Plans and limits
The SDK is the same on every plan. Limits come from the features it calls, for example files.
Troubleshooting
Errors are AhamoError with a category (validation, authentication, authorization, conflict,
rate-limit, unavailable and others) and whether a retry is safe. Show the person a plain message and retry only
when the error says it is safe. A server function that throws on purpose arrives as function-failed with its
message.