Skip to Content

Installation

Add @osdk/client, @osdk/oauth, @osdk/react, and your generated SDK to an existing app, with the npm registry setup and version rules they need.

Add OSDK to an app you already have by installing the client packages and your generated SDK from your Foundry npm registry. To start from a new project with everything configured, use the Quickstart instead.

Before you start

Generate an SDK for your application in Developer Console with the npm package type, and note three values from its install instructions:

ValueExample
SDK package name@my-app/sdk
npm registry URLhttps://example.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.main.repository.<id>/contents/release/npm
Foundry tokenA token that can read that registry. Keep it out of source control.

Install

Point your SDK's scope at the Foundry registry

The generated SDK is not on the public npm registry. Add two lines to .npmrc in your project root: one maps your SDK's scope to the Foundry registry, and one authenticates every request to Foundry's artifacts API with a token from the environment.

.npmrc
//example.palantirfoundry.com/artifacts/api/:_authToken=${FOUNDRY_TOKEN}
@my-app:registry=https://example.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.main.repository.<id>/contents/release/npm/

Replace example.palantirfoundry.com with your Foundry host, @my-app with your SDK's scope, and the registry URL with yours. Keep the trailing / on the registry URL, which pnpm requires. This is the same file @osdk/create-app writes.

Export the token before you install, and set it as a secret in CI:

export FOUNDRY_TOKEN=<token>

Install the client packages and your SDK

npm install @osdk/client @osdk/api @osdk/oauth @my-app/sdk@latest
PackageWhy you need it
@osdk/clientcreateClient and the runtime that runs queries and actions.
@osdk/apiTypes shared by the client and your SDK.
@osdk/oauthToken providers for signing users in. See Authentication.
@my-app/sdkYour Ontology's generated definitions.

Add the React packages

Skip this step if you do not use React.

npm install @osdk/react react react-dom

@osdk/react supports React 17, 18, and 19. For prebuilt components, also install @osdk/react-components; its setup is on Components prerequisites.

Create the client

Create one client for your app and wrap your React tree in OsdkProvider. Create a client walks through both.

Version compatibility

@osdk/client, @osdk/api, and @osdk/react are released together and share a version number. @osdk/react imports its cache runtime from @osdk/client/observable, which is tied to the exact release line, so a mismatch fails at build time even when npm's peer ranges are satisfied.

  • Install the same version of all three. If @osdk/react is 2.83.0, use @osdk/client@2.83.0 and @osdk/api@2.83.0.

  • Keep prereleases together. A prerelease @osdk/react, such as -beta.3, needs the same prerelease of @osdk/client and @osdk/api. Pairing it with stable releases breaks.

  • Upgrade them in one command. Bump the three packages together, and include @osdk/react-components if you use it:

    npm install @osdk/client@latest @osdk/api@latest @osdk/react@latest
  • Your generated SDK has a peer dependency on @osdk/client. It is set to the client version that generated it, so install an @osdk/client that satisfies the SDK's peer range. When you upgrade the client across many versions, generate a new SDK version too.

A version mismatch usually shows up as one of these errors:

ErrorCauseFix
"<name>" is not exported by @osdk/client/.../observable.js (or @osdk/api/...)@osdk/client or @osdk/api is on a different release line than @osdk/react, often a prerelease paired with stable versions.Install the exact @osdk/client and @osdk/api versions that match @osdk/react.
npm or pnpm peer warning for @osdk/client or @osdk/apiThe declared peer ranges allow newer @osdk/client and @osdk/api releases than @osdk/react was built with, and, since 2.87.0, warn on older ones.Pin the matching versions instead of ignoring the warning.

Optional peers for Platform APIs

Hooks from @osdk/react/platform-apis, such as useCurrentFoundryUser, useFoundryUser, and useMarkings, call Foundry Platform APIs through two optional peer dependencies. Install them only if you import from that entry point:

npm install @osdk/foundry.admin @osdk/foundry.core

Without them, a build that imports @osdk/react/platform-apis fails with Rollup failed to resolve import "@osdk/foundry.admin" (or @osdk/foundry.core). See Platform APIs.

Bundler setup

OSDK packages read process.env.NODE_ENV, which Vite does not define by default. Without it the browser throws ReferenceError: process is not defined. Use OSDK with Vite shows the define setting and a local CORS proxy to Foundry.

On this page