One script tag gives your game login and analytics. A second package gives it cloud saves.
What you get
<script src="https://strafe.fun/js/strafe.js"></script>
<script>
const strafe = new Strafe({ appId: 'your-app-id' });
</script>That single line mounts the login widget and starts measuring sessions. Analytics needs no further setup. From npm instead:
npm install @strafe-fun/sdk
import { StrafeClient } from '@strafe-fun/sdk/browser';
const strafe = new StrafeClient({ appId: 'your-app-id' });Only needed for cloud saves and for reacting to logins on your own game server.
const { Strafe } = require('@strafe-fun/sdk/server');
const strafe = new Strafe({
appId: 'your-app-id',
appSecret: process.env.STRAFE_APP_SECRET,
});
strafe.on('playerJoin', (player) => {
console.log(player.id); // unique player id
console.log(player.name); // display name
console.log(player.data); // saved data (already loaded)
});
// Save player data any time
strafe.savePlayerData(player.id, { highScore: 9001 });Check it worked
Open the sandbox with your App ID. It loads the real SDK, sends real events, and tells you which ones we received, usually within a second or two.
Then open your own game and watch the same checklist under Settings → Setup on your game's page. Every line there is something we actually received, so nothing reads as “working” until it genuinely is.
From your game's own console, the same check by hand:
// in the page where you created the client
await fetch('https://strafe.fun/api/sdk/verify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
appId: strafe.getAppId(),
sessionId: strafe.getSessionId(),
deviceId: strafe.getDeviceId(),
}),
}).then(r => r.json()).then(console.log);
// { app: { exists: true, active: true },
// session: { startedAt: '...', durationSec: 0, identity: 'device' }, ... }session: null means nothing arrived. Check the App ID, and check the browser console for a blocked request. Full details in the API reference.