Installation
Install the Gamebeast JavaScript SDK, create the right API key, and send your first marker from a browser or a server.
If you haven't created a project in the Gamebeast dashboard yet, please start with the Getting Started guide. When you create the project, pick Other as its platform (or Unity / Discord if this is the web or server side of one of those games). Gamebeast validates markers against the project's platform, and Roblox projects expect the Roblox SDK's marker format, so give a web app its own project rather than reusing a Roblox one.
Installing the SDK
The SDK is published to npm as @gamebeast/sdk. It has no runtime dependencies and ships ESM and CommonJS builds with TypeScript types.
npm install @gamebeast/sdkThe package has two entry points. Import the one that matches where your code runs:
| Import | Runs in | API key |
|---|---|---|
@gamebeast/sdk/client | Browsers, web apps, web workers | SDK Key |
@gamebeast/sdk/server | Node.js 20+, Bun, Deno, edge runtimes, serverless functions | Server Key |
Anything in a browser bundle is visible to your users. Never put a Server Key in code that imports
@gamebeast/sdk/client.
Creating an API key
- In the dashboard, open Project Settings from the left side.
- Press Create API Key. Create an SDK Key for browser code, and a Server Key for your backend.
- Copy the key before closing the popup. You won't be able to see it again.
Start the SDK
import { GamebeastClient } from "@gamebeast/sdk/client";
// One instance per page; a module-level singleton works well.
export const gamebeast = new GamebeastClient({
apiKey: "YOUR_SDK_KEY", // Replace with your SDK Key.
});
gamebeast.markers.send("page_opened", { path: location.pathname });And that's it! You're now ready to start sending data to the Gamebeast dashboard.
Testing against development
Both SDKs target the Production environment unless you pass environment. While you're building, point them at Development so test data stays out of your live numbers:
new GamebeastClient({ apiKey: "YOUR_SDK_KEY", environment: "development" });Custom environments work too: pass the name from Copy environment name in the dashboard's environment selector, such as "staging". Configurations and experiments use custom environments directly. Markers and cohort checks only support Production and Development, so they go to Development from a custom environment, and the SDK warns you about it once at startup.
Migrating from @gamebeast/node
@gamebeast/sdk/server replaces the older @gamebeast/node package:
@gamebeast/node | @gamebeast/sdk/server |
|---|---|
Gamebeast.setup({ ... }) | const gamebeast = new GamebeastServer({ apiKey, ... }) |
Gamebeast.getConfig(name) | gamebeast.configs.get(path), or await gamebeast.configs.evaluate({ distinctId, configuration }) for per-user values |
markers.sendMarker(name, value) | gamebeast.markers.send(name, properties) |
markers.sendUserMarker(userId, name, value) | gamebeast.markers.send(name, properties, { distinctId: userId }) |
Call await gamebeast.shutdown() before the process exits so buffered markers are delivered.