Rudder

Rudder SDK packages

@rudder/sdk (1.0.0)

Published 2026-10-28 16:48:49 +01:00 by edmand46 in rudder/rudder-js-sdk

Installation

@rudder:registry=https://hub.rudder.build/api/packages/rudder/npm/
npm install @rudder/sdk@1.0.0
"@rudder/sdk": "1.0.0"

About this package

@rudder/sdk

The game client of Rudder for the browser and Node. It signs a device in and calls the functions of the modules of a project through a typed client generated for that project. It has no runtime dependencies.

Install

The package comes from the Rudder registry. Point the scope @rudder at it in the .npmrc of the game:

@rudder:registry=https://hub.rudder.build/api/packages/rudder/npm/

then install it:

npm install @rudder/sdk

Generate the client

In a repository where rudder project use chose the project:

rudder client generate --lang ts --output src/rudder.ts --game-address https://api.rudder.build \
  [--environment staging|prod]

The client follows the newest release of the environment, staging by default: a class per module with a method per function a game client may call (functions marked server are left out) and the types of their arguments and results. Generate it again when a release changes them.

Use

import { Rudder } from './rudder';

const rudder = await Rudder.signInDevice(sdkKey, deviceId);
const stores = await rudder.stores.stores();
await rudder.stores.buy({ offer: 'pumpkin-pack' });
const balances = await rudder.session.wallet();

The third argument of signInDevice takes address (the origin of the page, or the address given to --game-address, when missing), attempts, fetch and the nickname, avatar, language and region of the player.

  • Errors. A refused call throws RudderError with the code, message and HTTP status of the answer: a code the module declares (such as limit_reached) or one of Rudder (such as player_banned, idempotency_key_reused or rate_limited).
  • Retries. A request that got no answer or the answer try_again is sent again after the Retry-After it gave or a short backoff, at most attempts times (5). A mutation keeps its Idempotency-Key across them, so it runs once. Pass your own key, such as the id of a purchase, to keep that promise across restarts: buy(input, { idempotencyKey }).
  • Session. The access token stays in memory; when it expires the device signs in again.
  • Cancel. Every method takes the option signal, an AbortSignal.

Dependencies

Development Dependencies

ID Version
@types/node ~24.10.0
typescript ~5.9.3
Details
npm
2026-10-28 16:48:49 +01:00
1
3.5 KiB
Assets (1)
sdk-1.0.0.tgz 3.5 KiB
Versions (4) View all
1.2.0 2026-11-01
1.1.0 2026-10-29
1.0.1 2026-10-29
1.0.0 2026-10-28