Skip to main content

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 casePackageIncludes
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 install @xaiku/browser
import xaiku from '@xaiku/browser'

const sdk = xaiku({
pkey: 'pk_your_public_key',
experimentIds: ['your_experiment_id'],
})

React

npm install @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 install @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
.env.local
NEXT_PUBLIC_XAIKU_API_KEY=pk_your_public_key

See the Next.js quickstart for the full setup.

Node.js

npm install @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 install @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