Friends, shares, and a friends leaderboard
3 min read
A global leaderboard with a stranger named xX_pro_Xx at the top motivates almost nobody. Being 40 points behind your actual friend, whose name you know, is the itch players can't stop scratching. Social competition is the retention lever, and the invite that creates it is your cheapest, most viral growth channel. The trick is making that invite carry context, so the person who taps it lands in a story instead of a login wall.
Triggair's social layer gives you three moving parts: friends, a friends-only leaderboard slice, and shareable codes that resolve before the invitee has even logged in.
Start with friends. A friend request auto-accepts when it's mutual, and once two players are connected you can read a leaderboard sliced to just that friend graph.
await tg.social.request(playerId);
// A mutual request auto-accepts — there's no separate accept step.
// The board, but only your friends on it
const friendsTop = await tg.leaderboards.friends('weekly_sprint');
That friends slice is the whole psychological payload: a short, personal ladder where every name is someone the player actually knows.
Now the viral part. When a player does something worth bragging about, mint a share code that captures the context: a score to beat, a challenge, a level.
const { code } = await tg.social.share({
type: 'beat_my_score',
board: 'weekly_sprint',
score: 8420,
from: (await tg.players.me()).id,
});
const url = `https://yourgame.com/?s=${code}`;
// drop `url` into a Web Share sheet, a Discord message, wherever
The magic is on the receiving end: resolveShare works before login. So when someone opens ?s=CODE, you can read the context and render a personalized landing screen ("Tibi challenged you to beat 8,420") before asking them to sign in. The context survives the whole onboarding.
const params = new URLSearchParams(location.search);
const code = params.get('s');
if (code) {
const { context } = await tg.social.resolveShare(code); // no login needed
showChallengeScreen(context); // "Beat 8,420 in Weekly Sprint"
}
// …then, after they're hooked and sign in:
await tg.login();
Because you resolved the challenge first, the new player understands exactly why they're here and who sent them. That framing (a specific human threw down a specific gauntlet) converts far better than a generic "Play now."
Going further
- Auto-friend the inviter. When a
?s=CODEinvitee finishes signing up, calltg.social.request(context.from). A mutual request auto-accepts, so the two land on each other's friends leaderboard immediately. The loop closes itself. - Share the moment, not the app. A code minted at a peak (a new high score, a boss kill) carries emotional context a bare link can't. Mint the share right when the bragging instinct fires.
- Resolve early, login late. Reading context before
tg.login()is the difference between a warm landing and a cold wall. Always resolve the code first.
Strangers are noise; friends are stakes. Wire share codes to friend requests to a friends-only board, and every player you have becomes a doorway to the next one, each invite carrying a real challenge instead of a shrug.