Add login and cloud saves to your game in 2 steps.
<script src="https://www.indie.fun/js/indie.js"></script>
<script>
new Indie({ appId: 'your-app-id' });
</script>A login widget appears automatically. Players log in, and the event is sent to your game server.
Anonymous players are counted toward daily active users and retention. By default (consent: 'auto') the SDK shows a small bar to first-time visitors so players are always told — in the EU/UK it asks permission and counts nobody until they Allow; elsewhere it's a notice with a Decline option that dismisses itself. Either way it appears once and is remembered. To use your own consent UI instead, set consent: 'manual' and call the SDK when the player chooses:
const indie = new Indie({ appId: 'your-app-id', consent: 'manual' });
// from your own banner:
indie.optIn(); // allow anonymous analytics
indie.optOut(); // decline (also stops tracking)
indie.getConsent(); // 'granted' | 'denied' | 'unknown'Do Not Track / Global Privacy Control are always honored. Logged-in players are counted regardless. Use consent: 'off' only if your site handles consent itself.
npm install indie-sdkconst { Indie } = require('indie-sdk/server');
const indie = new Indie({
appId: 'your-app-id',
appSecret: 'your-app-secret',
});
indie.on('playerJoin', (player) => {
console.log(player.id); // unique player ID
console.log(player.name); // display name
console.log(player.data); // saved game data (guaranteed loaded)
console.log(player.permissions); // { chat: true, vip: false }
});
// Save player data anytime
indie.savePlayerData(player.id, { highScore: 9001 });That's it. See the API Reference for details.