# Glint SDK Quickstart

Go from an empty folder to a published Glint game: install the SDK and CLI, scaffold a starter, preview it in the Local Emulator, validate it, and upload it in Glint Studio.

The Glint SDK (`@joinfoundry/glint-sdk`) connects a browser game to Glint: loading progress, pause and mute, cloud saves, achievements, leaderboards, controller remapping (`sdk.input`), and multiplayer rooms. The same package includes the `glint` CLI, which scaffolds starters, runs a Local Emulator with Glint's sandbox, and validates builds before upload.

## What You Need

- Node.js 20 or later.
- A Foundry account that can use Glint Studio. See [Create a Game](https://joinfoundry.xyz/help/glint/create-a-game).
- A game. You can start from one of the starters below or bring an existing browser build.

## Install and Update the CLI

The CLI is the `glint` command in the scoped `@joinfoundry/glint-sdk` package. Update to the latest version before you start a build or upload one. Newer versions carry the current validation rules.

```bash
# Check the latest published version on npm
npm view @joinfoundry/glint-sdk version

# Install or update globally
npm install --global @joinfoundry/glint-sdk@latest
glint help
```

To run the latest CLI from any folder without a global install or a stale `npx` cache, pass `-p @joinfoundry/glint-sdk@latest`:

```bash
npx --yes --prefer-online -p @joinfoundry/glint-sdk@latest glint <command>
```

Inside a project that already lists `@joinfoundry/glint-sdk` as a dependency (the Phaser, Three.js and KAPLAY starters do), update it with `npm install @joinfoundry/glint-sdk@latest` and then `npx glint <command>` runs the installed copy. Bare `npx glint` fails in folders where `@joinfoundry/glint-sdk` isn't installed.

## Create a Starter

```bash
glint init vanilla-ts my-game
```

`init` copies a starter into the folder you name (the current folder if you leave it out) and adds `glint.js`, the browser build of the SDK. Files with the same names in that folder are overwritten.

| Template | What you get |
| --- | --- |
| `vanilla-ts` | A canvas game in plain JavaScript with no build step. It saves the best score to a cloud save slot. This is the default. |
| `multiplayer-ts` | A canvas arena with Quick Join, Create Room and Invite buttons, binary position updates and host migration. |
| `phaser` | Phaser 3 with Vite. |
| `threejs` | Three.js with Vite. |
| `kaplay` | KAPLAY with Vite. |
| `godot` | The Godot 4.3+ adapter: `Glint.gd`, an export preset and an HTML shell. See [Godot 4.3+](https://joinfoundry.xyz/help/developers/glint-sdk-godot). |
| `unity` | The Unity WebGL adapter: `Glint.jslib`, `Glint.cs` and a WebGL template. See [Unity WebGL](https://joinfoundry.xyz/help/developers/glint-sdk-unity). |

The `vanilla-ts` starter is ready to play as it is: `index.html`, `main.js`, `glint.json` and `glint.js`.

## Add the SDK to Your Game

Every game needs the same few calls: start the SDK, report loading progress, say when the first screen is interactive, stop on pause, and follow Glint's mute button.

```js tab="Script tag"
// index.html loads ./glint.js before your game script.
const sdk = await window.Glint.init();
sdk.lifecycle.loadingProgress(0.5);

let muted = sdk.system.isMuted();
sdk.system.onMuteChange(next => { muted = next; });
sdk.lifecycle.onPause(() => { /* stop requestAnimationFrame, physics and audio */ });
sdk.lifecycle.onResume(() => { /* start the loop again */ });

sdk.lifecycle.ready();
```

```ts tab="npm"
import { Glint } from "@joinfoundry/glint-sdk";

const sdk = await Glint.init();
sdk.lifecycle.loadingProgress(0.5);

let muted = sdk.system.isMuted();
sdk.system.onMuteChange(next => { muted = next; });
sdk.lifecycle.onPause(() => { /* stop requestAnimationFrame, physics and audio */ });
sdk.lifecycle.onResume(() => { /* start the loop again */ });

sdk.lifecycle.ready();
```

Outside Glint, `Glint.init()` still resolves, with a standalone fallback, so the same build runs when you open it directly. Everything else the SDK can do is in the [JavaScript API Reference](https://joinfoundry.xyz/help/developers/glint-sdk-api). For engine-specific setup, see [Web Engines](https://joinfoundry.xyz/help/developers/glint-sdk-web-engines).

## Preview in the Local Emulator

```bash
glint preview my-game
```

Open `http://127.0.0.1:4173`. The Local Emulator serves your build from a separate local origin with Glint's production Content Security Policy, so anything that would break on Glint breaks here too. Its toolbar mutes, pauses and resumes the game, switches between free, demo, owned and Glint Pass modes, and spawns extra players. Add `--players 2` to open two panes for multiplayer. See [preview](https://joinfoundry.xyz/help/developers/glint-sdk-cli#preview).

## Validate the Build

```bash
glint validate my-game
```

The validator checks the folder or ZIP against Glint's rules and budgets, then prints PASS or FAIL, a Performance Score out of 100 and whether the build qualifies for the Loads Fast badge. Errors make the command fail. Fix every error and as many warnings as you can; each code is explained in [Error and Warning Codes](https://joinfoundry.xyz/help/developers/glint-sdk-cli#error-and-warning-codes).

## Package the Build

Zip the contents of the build folder so that `index.html` and `glint.json` sit at the top level of the ZIP, not inside a folder. For the Phaser, Three.js and KAPLAY starters, the build folder is `dist` after `npm run build`. Use standard ZIP compression and leave the files themselves uncompressed: Glint compresses them with Brotli when you upload. The full layout rules are in [Platform Rules and Budgets](https://joinfoundry.xyz/help/developers/glint-sdk-platform-rules#zip-layout).

## Upload and Publish

You can upload from the command line or in Glint Studio (`glint.joinfoundry.xyz/studio`, under **Glint Studio** in the account menu):

1. **From the CLI:** Create a Foundry personal token with **Marketplace write** (`marketplace:write`) access in [AI Agents settings](https://joinfoundry.xyz/workspace/agents), set `FOUNDRY_API_TOKEN`, and run:
   ```bash
   npx --yes --prefer-online -p @joinfoundry/glint-sdk@latest glint publish my-game --interactive
   ```
   This creates or updates your Glint Studio game, uploads your cover and screenshots, packages and uploads the build ZIP, waits for Package X-Ray and Brotli repackaging, and prints a link to the game in Glint Studio. For later builds, use `glint upload my-game --game <id-or-slug>`.
2. **Or in Glint Studio:** Create the game in Glint Studio ([Create a Game](https://joinfoundry.xyz/help/glint/create-a-game)) and upload the ZIP in **Build & X-Ray** ([Upload a Build](https://joinfoundry.xyz/help/glint/upload-a-build)). Drafts appear in the **Releases** list on the Glint Studio home page.
3. If your game unlocks achievements or submits scores, define their keys in Glint Studio or with the MCP tools `glint_upsert_achievement` and `glint_upsert_leaderboard`. See [Achievements and Leaderboards](https://joinfoundry.xyz/help/glint/achievements-and-leaderboards).
4. Open your game in Glint Studio, answer the **Content rating** questions, confirm your publishing rights, add seller details if the game is paid, and click **Publish**. See [Ratings and Publishing](https://joinfoundry.xyz/help/glint/ratings-and-publishing).

## Next Steps

- [Platform Rules and Budgets](https://joinfoundry.xyz/help/developers/glint-sdk-platform-rules): the sandbox, file layout and size limits.
- [Manifest Reference](https://joinfoundry.xyz/help/developers/glint-sdk-manifest): every field in `glint.json`.
- [JavaScript API Reference](https://joinfoundry.xyz/help/developers/glint-sdk-api): saves, achievements, leaderboards, controller remapping (`sdk.input`) and multiplayer.
- [CLI and Local Emulator](https://joinfoundry.xyz/help/developers/glint-sdk-cli): every command, flag and validator code.
- [Building With an AI Agent](https://joinfoundry.xyz/help/developers/glint-sdk-ai-agents): Foundry's MCP tools and the portable skill file.
- If a published game doesn't load, see [Troubleshooting](https://joinfoundry.xyz/help/glint/troubleshooting).
