> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gamavas.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Add “Sign in with Gamavas” to a web game, unlock your first achievement, and know who's playing, in about five minutes.

This guide uses the web SDK: a single script tag, so it works with any framework or none. Using an engine? The steps in the portal are the same. Then follow your engine's guide, for example [Unity](https://docs.gamavas.fun/sdks/unity.md).

**1. Connect your game**

Sign in at [developer.gamavas.fun](https://developer.gamavas.fun) with your Gamavas account and choose **Connect a game**. Pick your game's listing and add the page your game runs on under **Where sign-in returns**, for example `https://your-game.example/`.

You get a **client ID**. It's public, so it's fine to put in your game's code.

> [!NOTE]
>
> Sign-in only returns to addresses you add here, exactly as written. Testing locally? Add `http://localhost:5173/` (your port) as well.

**2. Add the script and the button**

Load the Gamavas script on that page, as early as you can, and place the button where players sign in:

```html index.html theme={"theme":{"light":"github-light","dark":"github-dark"}}
<head>
  <script src="https://gamavas.fun/sdk/pass.js"></script>
</head>
<body>
  <gamavas-signin client-id="YOUR_CLIENT_ID" theme="dark"></gamavas-signin>
</body>
```

The button opens a small Gamavas popup. Players sign in or create an account, approve your game once, and the popup closes.

**3. Know who's playing**

The button fires `gamavas-signin` with the player's profile, and a `pass` client for everything else:

```js game.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
document.addEventListener("gamavas-signin", (event) => {
  const { player, pass } = event.detail;
  // player: { id, handle, displayName, avatarUrl, email }
  startGame(player);
});

document.addEventListener("gamavas-error", (event) => {
  // event.detail.error.code: "popup_closed", "access_denied", …
});
```

`player.id` is the player's Gamavas ID: the same in every game, so it's the one to store. Players stay signed in between visits, and a returning player sees **Continue as @handle**.

**4. Unlock an achievement**

In the portal, open your app, go to **Achievements** and add one with the key `first-win`. Then unlock it from your game:

```js theme={"theme":{"light":"github-light","dark":"github-dark"}}
const result = await pass.unlock("first-win");
if (result.newlyUnlocked) {
  console.log(`+${result.xpAwarded} XP`); // Gamavas also shows an "Achievement unlocked" notice
}
```

The XP adds to the player's Gamavas level, which they carry to every game.

That's it: your game has accounts and achievements. You can see sign-ins, unlocks and play time on your app's **Analytics** page.

## Using JavaScript instead of the button

For your own button or more control, create the client yourself. Call `signIn()` from a click, because browsers only allow popups then:

```js theme={"theme":{"light":"github-light","dark":"github-dark"}}
const pass = GamavasPass.create({ clientId: "YOUR_CLIENT_ID" });

await pass.ready;                 // finishes a sign-in that came back to this page
pass.user;                        // the signed-in player, or null

signInButton.onclick = async () => {
  const player = await pass.signIn();             // or signIn({ email: true })
};

pass.onChange((player) => { /* signed in or out */ });
await pass.signOut();             // signs out of your game, not of Gamavas
```

> [!TIP]
>
> If the browser blocks the popup anyway, `signIn()` switches to a full-page sign-in, and `pass.ready` finishes it when the player comes back.

## Next steps

> [card] [Achievements and XP](https://docs.gamavas.fun/pass/achievements.md)
>
> Define achievements, server-only unlocks and XP limits.

> [card] [Sell your game](https://docs.gamavas.fun/pass/selling.md)
>
> Prices, checkout, refunds and getting paid.

> [card] [Your server](https://docs.gamavas.fun/pass/your-server.md)
>
> Verify players and unlock achievements from your server.

> [card] [Engine SDKs](https://docs.gamavas.fun/sdks/unity.md)
>
> Unity, Godot, Construct 3, GameMaker and Defold.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.