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

# Quickstart

> Build a single-player mini game from the Tap Tap template and play it in a browser

Tap Tap is the smallest single-player mini game: tap the button as many times as you can in 10 seconds. It does not connect to the game service or use game energy. It shows the SDK features every game uses. The source is in `games/hello` in the server repository.

## Files

```text theme={null}
hello/
├── manifest.json   package manifest
├── index.html
├── style.css
├── main.js
└── pack.sh         packs the game into a .nlgame
```

The game package CSP does not allow inline scripts, so put scripts in separate files.

## manifest.json

```json theme={null}
{
  "schema": 1,
  "id": "hello",
  "name": "Tap Tap",
  "version": "0.1.0",
  "build": 1,
  "entry": "index.html",
  "orientation": "portrait",
  "background": "#10202a",
  "sdk": ">=1.0 <2",
  "scopes": ["game.identity", "game.energy.read", "game.haptics", "game.share"],
  "network": { "connect": [], "img": [] },
  "players": { "min": 1, "max": 1 }
}
```

`id` must match the app's identifier on the forum. See [Manifest, scopes, and game packages](https://docs.nodeloc.com/en/minigames/manifest.md) for the fields.

## index.html

```html theme={null}
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, user-scalable=no">
  <link rel="stylesheet" href="style.css">
  <script src="nl-game-sdk.js"></script>
  <script src="main.js" defer></script>
</head>
<body>
  <header><img id="avatar" alt=""><b id="name">…</b><small id="energy"></small></header>
  <main><button id="target" type="button">Start</button><p id="score"></p></main>
  <footer>
    <button id="share" type="button" hidden>Invite a friend</button>
    <p id="signin" hidden><button id="login" type="button">Sign in</button> to show your name and game energy</p>
  </footer>
</body>
</html>
```

## Key parts of main.js

```javascript theme={null}
async function boot() {
  nl.setLoadingProgress(0.5);
  try {
    // The host's "Exit" capsule is in the top-right corner; keep the title bar clear of it
    const cap = await nl.ui.getCapsuleRect(); // {x, y, width, height}
    if (cap.width > 0) document.querySelector("header").style.paddingRight = `${innerWidth - cap.x + 8}px`;
  } catch {}
  await nl.ready(); // Close the host loading screen, as early as possible
  loadUser();
}

async function loadUser() {
  try {
    const me = await nl.auth.getUser();
    $("name").textContent = me.name || me.username;
    if (me.avatar) $("avatar").src = me.avatar;
  } catch (e) {
    if (e.code === "AUTH_REQUIRED") { $("signin").hidden = false; return; } // Being signed out is not a network error
  }
  try {
    const w = await nl.energy.getWallet();
    $("energy").textContent = `Game energy ${w.balance}`;
  } catch {} // SCOPE_DENIED when the scope is not approved
}

// Sign-in must be called from a click handler
$("login").addEventListener("click", () => nl.auth.login().then(loadUser, () => {}));
$("target").addEventListener("click", () => { /* count */ nl.haptics.impact("light"); });
$("share").addEventListener("click", () => nl.share.invite({ title: "Tap Tap", text: "Come play Tap Tap" }));
nl.lifecycle.on("pause", () => { /* void the current round when sent to the background */ });
boot();
```

## Pack and play

`pack.sh` zips the files together with the SDK:

```bash theme={null}
games/hello/pack.sh 2        # creates games/hello/dist/hello-0.1.0-2.nlgame
```

After uploading, open `https://www.nodeloc.com/games/hello` in a browser. The forum redirects to the web version and completes authorization. See [Local development and publishing](https://docs.nodeloc.com/en/minigames/publishing.md) for uploading and local debugging.

## Next steps

1. Copy the template and change `id`, `name`, and `orientation` in `manifest.json`.
2. List only the scopes you use in `scopes`. Each extra scope is one more item to check in review and one more item the user confirms on first authorization.
3. For multiplayer matches, read [Real-time matches](https://docs.nodeloc.com/en/minigames/realtime.md) and [Rulesets](https://docs.nodeloc.com/en/minigames/rulesets.md).


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