<!-- 0Gkit docs — Templates
     Source: https://docs.0gkit.com/templates
     LLM-friendly Markdown twin of the page. -->

# Templates

0gkit ships **nine** starter projects so you can go from zero to a running 0G
app in one command. Each is a minimal, correct, copy-and-go example focused
on one surface.

Scaffold any of them with `create-0gkit-app`:

```bash
npm create 0gkit-app@latest my-app -- --template <name>
cd my-app && pnpm install && pnpm dev
```

…or with `degit` if you want just the files (no git history):

```bash
npx degit rajkaria/0gkit/templates/<name> my-app
cd my-app && pnpm install
```

> The CLI also scaffolds a minimal read-only project with no template needed:
> `npx @foundryprotocol/0gkit-cli init my-app` (writes `package.json`, `.env.example`, `index.mjs`,
> `README.md`, `.gitignore`). Use that for a bare start; use a template below
> for a focused, surface-specific example.

## Under 5 minutes — time to first success

Every template ships a `0g.config.ts` (typed env via
[`define0GConfig`](/packages/core)) and prints the first-success banner
`[0gkit:first-success]` on its first 0G op so you know it worked. Approximate
local time from `npm create` to that banner:

| Template             | Primary primitive           | Time-to-first-success |
| -------------------- | --------------------------- | --------------------- |
| `storage-app`        | Storage upload + dedup      | ~45s                  |
| `inference-app`      | Compute inference           | ~45s                  |
| `attestation-verify` | Attestation (pure crypto)   | ~30s                  |
| `mcp-agent`          | MCP server (stdio)          | ~30s                  |
| `nft-with-storage`   | Storage + contract mint     | ~60s                  |
| `ai-agent`           | Compute + durable jobs      | ~60s                  |
| `tee-attested-api`   | Hono + TEE attestation      | ~60s                  |
| `chat`               | Next.js + Storage + indexer | ~90s                  |
| `react-app`          | Next.js + 0gkit-react hooks | ~90s                  |

---

## The five canonical archetypes (SP8)

### `chat`

Real-time chat where messages live on **0G Storage** and the on-chain
`MessagePosted` event log is the source of truth for the message list. Uses
the SP6 reorg-safe `useEvent` hook so rolled-back messages disappear
automatically.

```bash
npm create 0gkit-app@latest my-chat -- --template chat
```

Surfaces demoed: wallet + storage + indexer + react + typed contracts.
Best when: building anything where users post → the chain remembers.

### `storage-app`

Upload + retrieve a file with **SP7 dry-run preflight** (predict cost + Merkle
root before broadcasting), **dedup** (skip the funding tx if the root already
exists), and round-trip verify. Uses
[`@foundryprotocol/0gkit-storage`](/packages/storage) +
[`@foundryprotocol/0gkit-core`](/packages/core).

```bash
npm create 0gkit-app@latest my-store -- --template storage-app
```

Surfaces demoed: wallet + storage + SP7 estimator.
Best when: persisting datasets/artifacts to 0G.

### `ai-agent`

Multi-step **LangChain-style ReAct agent** on 0G Compute, where every
inference step's TEE attestation is verified before its decision is acted
on. In-process loop today; documented hand-off path for SP10
(`0gkit-jobs`).

```bash
npm create 0gkit-app@latest my-agent -- --template ai-agent
```

Surfaces demoed: wallet + compute + attestation.
Best when: chained model reasoning with auditable enclave provenance.

### `tee-attested-api`

A **Hono** HTTP API where every response carries an `X-0G-Attestation`
header. Clients can verify cryptographically that the response originated
inside genuine enclave hardware. Plain `console.log` access logging today;
documented hand-off for SP11 (`0gkit-observability`).

```bash
npm create 0gkit-app@latest my-api -- --template tee-attested-api
```

Surfaces demoed: wallet + attestation + compute.
Best when: shipping a public API whose payloads need provenance.

### `nft-with-storage`

A Foundry-deployed ERC-721 where both the metadata JSON **and** the media
file live on 0G Storage. `tokenURI(id)` returns `0g-storage://<merkleRoot>`.
Uses SP4 typed-contract codegen.

```bash
npm create 0gkit-app@latest my-nft -- --template nft-with-storage
```

Surfaces demoed: wallet + storage + SP4 typed contracts.
Best when: minting collectibles with on-chain provenance + off-chain payloads.

---

## The four Phase-1 starters

### `inference-app`

A Node script that runs a chat completion against a 0G compute provider and
prints the on-chain fee receipt, including the OpenAI drop-in shim. Uses
[`@foundryprotocol/0gkit-compute`](/packages/compute).

```bash
npm create 0gkit-app@latest my-infer -- --template inference-app
```

Best when: running paid LLM inference on 0G, or migrating OpenAI code.

### `attestation-verify`

A pure, no-network, no-keys example that signs and verifies a TEE attestation
envelope and prints a report. Uses
[`@foundryprotocol/0gkit-attestation`](/packages/attestation).

```bash
npm create 0gkit-app@latest my-attest -- --template attestation-verify
```

Best when: producing or checking signed eval-result attestations.

### `mcp-agent`

A ready-to-wire MCP setup so Claude / Cursor / Cline can drive 0G. Includes
the client config blocks from the [MCP guide](/mcp) and an embedding example
with [`@foundryprotocol/0gkit-mcp`](/packages/mcp).

```bash
npm create 0gkit-app@latest my-mcp -- --template mcp-agent
```

Best when: giving an LLM agent direct, glue-free 0G access.

### `react-app`

A Next.js client component using the
[`@foundryprotocol/0gkit-react`](/packages/react) hooks — browser-side
attestation verify plus a server route for the Node-only upload/inference
path.

```bash
npm create 0gkit-app@latest my-ui -- --template react-app
```

Best when: building a 0G-powered React UI.

## Deploy on Vercel

Every template ships with a one-click Vercel deploy button in its README. The
button forks the template into a new repo under your GitHub account, prompts
for the env vars below, and deploys on **Fluid Compute** in under 60 seconds.

| Template             | Required env vars                                             | Deploy                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chat`               | `NETWORK`, `PRIVATE_KEY`                                      | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Fchat&project-name=0gkit-chat&env=NETWORK%2CPRIVATE_KEY&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                                                       |
| `storage-app`        | `NETWORK`, `PRIVATE_KEY`                                      | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Fstorage-app&project-name=0gkit-storage-app&env=NETWORK%2CPRIVATE_KEY&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                                         |
| `ai-agent`           | `NETWORK`, `PRIVATE_KEY`                                      | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Fai-agent&project-name=0gkit-ai-agent&env=NETWORK%2CPRIVATE_KEY&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                                               |
| `tee-attested-api`   | `NETWORK`, `PRIVATE_KEY`, `OTEL_EXPORTER_OTLP_ENDPOINT` (opt) | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Ftee-attested-api&project-name=0gkit-tee-attested-api&env=NETWORK%2CPRIVATE_KEY%2COTEL_EXPORTER_OTLP_ENDPOINT&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars) |
| `nft-with-storage`   | `NETWORK`, `PRIVATE_KEY`, `RPC_URL`                           | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Fnft-with-storage&project-name=0gkit-nft-with-storage&env=NETWORK%2CPRIVATE_KEY%2CRPC_URL&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                     |
| `inference-app`      | `NETWORK`, `PRIVATE_KEY`                                      | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Finference-app&project-name=0gkit-inference-app&env=NETWORK%2CPRIVATE_KEY&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                                     |
| `react-app`          | `NETWORK`, `WALLETCONNECT_PROJECT_ID` (opt)                   | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Freact-app&project-name=0gkit-react-app&env=NETWORK%2CWALLETCONNECT_PROJECT_ID&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                                |
| `mcp-agent`          | `NETWORK`, `PRIVATE_KEY`                                      | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Fmcp-agent&project-name=0gkit-mcp-agent&env=NETWORK%2CPRIVATE_KEY&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                                             |
| `attestation-verify` | `NETWORK`                                                     | [![Deploy](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frajkaria%2F0gkit%2Ftree%2Fmain%2Ftemplates%2Fattestation-verify&project-name=0gkit-attestation-verify&env=NETWORK&envDescription=See%200gkit.com%20env%20vars&envLink=https%3A%2F%2F0gkit.com%2Fgetting-started%2Fenv-vars)                                         |

## After scaffolding

Every template is testnet-first (Galileo) — no real funds needed. Run
`npx @foundryprotocol/0gkit-cli doctor` to preflight, then follow the template's `README`. See
[Getting started](/getting-started) for environment variables and
[Troubleshooting](/troubleshooting) if a peer dependency complains.

## Add a kit after scaffolding

Kits are drop-in feature overlays you can apply to any template after
scaffolding. To see which kits are compatible with your project's base:

```bash
0g kits list
```

Then apply one or more:

```bash
0g add agent-memory
0g add ai-oracle sealed-inference
```

See the [Kits catalog](/kits) for a full list of available kits and what each
one adds.
