Official SDKs · TypeScript-first
AINative SDKs for React, Vue, Svelte & Next.js
One install per framework. Chat completions, credit balance, and ZeroDB — with idiomatic hooks and server helpers. All packages are TypeScript-first with generated types.
SDK catalog
| SDK | Package | Version | Framework |
|---|---|---|---|
| React | @ainative/react-sdk | 1.0.2 | React 18 |
| Vue | @ainative/vue-sdk | 1.0.0 | Vue 3 |
| Svelte | @ainative/svelte-sdk | 1.0.0 | Svelte 4 & 5 |
| Next.js | @ainative/next-sdk | 1.0.2 | Next 13/14 (App + Pages Router) |
| Types | @ainative/types | 1.0.0 | TS defs — framework-agnostic |
Install & init snippets
React SDK
v1.0.2React 18npm install @ainative/react-sdk
import { AINativeProvider, useChat, useCredits } from '@ainative/react-sdk';
// Wrap your app:
<AINativeProvider config={{ apiKey: 'your-key' }}>
<App />
</AINativeProvider>
// Inside a component:
const { messages, isLoading, sendMessage } = useChat({
model: 'llama-3.3-70b-instruct',
});
const { balance } = useCredits();Vue SDK
v1.0.0Vue 3npm install @ainative/vue-sdk
// main.ts — provide config once:
import { AINativeConfigKey } from '@ainative/vue-sdk';
app.provide(AINativeConfigKey, { apiKey: 'your-key' });
// Inside a component:
<script setup lang="ts">
import { useChat } from '@ainative/vue-sdk';
const { messages, isLoading, sendMessage } = useChat({
model: 'claude-sonnet-4-6',
});
</script>Svelte SDK
v1.0.0Svelte 4 & 5npm install @ainative/svelte-sdk
import { setAINativeConfig, createChat } from '@ainative/svelte-sdk';
// Set config once (e.g. in +layout.ts):
setAINativeConfig({ apiKey: 'your-key' });
// Create a reactive chat store:
const chat = createChat({ model: 'claude-sonnet-4-6' });
// In template: $chat.messages, $chat.isLoading, $chat.sendMessageNext.js SDK
v1.0.2Next 13/14 (App + Pages Router)npm install @ainative/next-sdk
// Server component — never ships the key to the client:
import { createServerClient, getApiKey } from '@ainative/next-sdk/server';
const client = createServerClient({ apiKey: await getApiKey() });
const balance = await client.credits.balance();
// Protected API route:
import { withAuth, createServerClient } from '@ainative/next-sdk/server';
export const POST = withAuth(async (req, { apiKey }) => {
const client = createServerClient({ apiKey });
const body = await req.json();
return Response.json(
await client.chat.completions.create({ messages: body.messages }),
);
});Shared types — @ainative/types
@ainative/types (v1.0.0) exports TypeScript definitions generated from AINative API schemas. Import it on both the frontend and backend to share types without pulling in a full SDK package.
npm install @ainative/types
import type { ChatMessage, CreditBalance } from '@ainative/types';The Next.js SDK's client helpers re-export the React hooks, so useChat and useCredits work the same in both packages.
Patterns & best practices
Keep API keys server-side
In Next.js use the /server import path (createServerClient, getApiKey). Never send your key to the browser.
One provider at the root
Wrap your app once in AINativeProvider (React) or call setAINativeConfig / app.provide at the root. Avoid re-initialising per component.
Share types across the stack
Install @ainative/types on both frontend and backend to eliminate type drift without pulling in the full SDK.
Namespace memory per project
When using MCP memory alongside the SDK, set OPENCODE_MEMORY_NAMESPACE so sessions stay isolated.
Get the ZeroDB SDKs Step-by-Step Guide
A free PDF workbook: install, init, and integrate the React, Vue, Svelte, or Next.js SDK into your project — step by step.
Frequently asked questions
What SDKs does AINative publish?
AINative publishes five TypeScript-first packages: @ainative/react-sdk (v1.0.2, React 18), @ainative/vue-sdk (v1.0.0, Vue 3), @ainative/svelte-sdk (v1.0.0, Svelte 4 & 5), @ainative/next-sdk (v1.0.2, Next 13/14 App Router + Pages Router), and @ainative/types (v1.0.0, shared TypeScript definitions generated from schemas).
What does the React SDK provide?
The @ainative/react-sdk package exports AINativeProvider (context wrapper), useChat (streaming chat with any AINative model), and useCredits (live credit balance). Wrap your app in AINativeProvider with your API key and call the hooks in any child component.
How does the Next.js SDK differ from the React SDK?
The @ainative/next-sdk adds server-side helpers: createServerClient (for React Server Components and API routes), getApiKey (reads the key server-side), and withAuth (middleware for protecting API routes). The client helpers re-export the React hooks, so useChat and useCredits work the same on both. Keep API keys server-side using the /server import path.
How do I use the Vue SDK?
Provide the config via app.provide(AINativeConfigKey, { apiKey: "your-key" }) in main.ts, then import useChat from @ainative/vue-sdk inside any <script setup> component. The hook returns messages, isLoading, and sendMessage as reactive refs.
How do I use the Svelte SDK?
Call setAINativeConfig({ apiKey: "your-key" }) once (in +layout.ts or a root component), then createChat({ model: "..." }) anywhere. createChat returns a reactive Svelte store — subscribe with $chat in your template.
What is @ainative/types?
@ainative/types (v1.0.0) exports TypeScript definitions generated from AINative API schemas. Use it to share types between your frontend and backend without depending on a full SDK package.