Installation
Xaiku provides framework-specific packages so you only ship the code you need. Each higher-level package re-exports its dependencies, so a single install is all that is required.
Which package should I install?
| Use case | Package | Includes |
|---|---|---|
| Vanilla JavaScript / any website | @xaiku/browser | @xaiku/core, @xaiku/shared |
| React single-page app | @xaiku/react | @xaiku/browser, @xaiku/core, @xaiku/shared |
| Next.js (App Router) | @xaiku/nextjs | @xaiku/react, @xaiku/browser, @xaiku/node, @xaiku/core, @xaiku/shared |
| Node.js server (Express, Fastify, etc.) | @xaiku/node | @xaiku/core, @xaiku/shared |
| Custom integration / library author | @xaiku/core | @xaiku/shared |
You never need to install transitive dependencies yourself. For example, installing @xaiku/react automatically brings in @xaiku/browser, @xaiku/core, and @xaiku/shared.
Browser
- npm
- pnpm
- yarn
npm install @xaiku/browser
pnpm add @xaiku/browser
yarn add @xaiku/browser
import xaiku from '@xaiku/browser'
const sdk = xaiku({
pkey: 'pk_your_public_key',
experimentIds: ['your_experiment_id'],
})
React
- npm
- pnpm
- yarn
npm install @xaiku/react
pnpm add @xaiku/react
yarn add @xaiku/react
import { XaikuProvider } from '@xaiku/react'
function App() {
return (
<XaikuProvider pkey="pk_your_public_key">
{/* your app */}
</XaikuProvider>
)
}
React 18 or 19 is required as a peer dependency.
Next.js
- npm
- pnpm
- yarn
npm install @xaiku/nextjs
pnpm add @xaiku/nextjs
yarn add @xaiku/nextjs
@xaiku/nextjs provides two entry points:
@xaiku/nextjs-- client-side React components and hooks@xaiku/nextjs/server-- server-side provider, middleware, and SDK factory
NEXT_PUBLIC_XAIKU_API_KEY=pk_your_public_key
See the Next.js quickstart for the full setup.
Node.js
- npm
- pnpm
- yarn
npm install @xaiku/node
pnpm add @xaiku/node
yarn add @xaiku/node
import xaiku from '@xaiku/node'
const sdk = await xaiku({
pkey: 'pk_your_public_key',
experimentIds: ['your_experiment_id'],
})
The Node.js factory is async because it fetches experiment variants during initialization.
Core (advanced)
- npm
- pnpm
- yarn
npm install @xaiku/core
pnpm add @xaiku/core
yarn add @xaiku/core
@xaiku/core is the base factory that all other packages build on. Use it directly only if you are building a custom integration or a new framework adapter. For standard use cases, prefer one of the higher-level packages above.
Next steps
- Configuration -- all factory options, storage backends, and API URL settings
- Architecture -- how the packages relate to each other