Install the Alien Mini App Boilerplate
Get started with the Alien Mini App boilerplate. This template includes authentication, payments, database, and the Alien SDK pre-configured.
Mini App Boilerplate Requirements
- Bun runtime installed
- Docker for local PostgreSQL
- An Alien account with a Mini App registered in the Dev Portal
Clone and Install the Repository
git clone https://github.com/alien-id/miniapp-boilerplate my-miniapp
cd my-miniappThe boilerplate ships the v2 @alien-id/miniapps-* SDK packages —
the same surface documented in the React SDK
reference pages.
Install Dependencies
bun installProject Structure
my-miniapp/
├── app/
│ ├── api/
│ │ ├── me/route.ts
│ │ ├── invoices/route.ts
│ │ ├── transactions/route.ts
│ │ └── webhooks/payment/route.ts
│ ├── store/page.tsx
│ ├── profile/page.tsx
│ ├── explore/page.tsx
│ ├── layout.tsx
│ ├── page.tsx
│ ├── providers.tsx
│ ├── error.tsx
│ └── global-error.tsx
├── components/
│ └── ui/
│ └── card.tsx
├── features/
│ ├── auth/
│ │ ├── components/
│ │ │ └── connection-status.tsx
│ │ └── lib.ts
│ ├── user/
│ │ ├── components/
│ │ │ └── user-info.tsx
│ │ ├── dto.ts
│ │ ├── hooks/
│ │ │ └── use-current-user.ts
│ │ └── queries.ts
│ ├── payments/
│ │ ├── components/
│ │ │ └── diamond-store.tsx
│ │ ├── hooks/
│ │ │ └── use-diamond-purchase.ts
│ │ ├── constants.ts
│ │ ├── dto.ts
│ │ └── queries.ts
│ ├── sdk-showcase/
│ │ └── components/
│ │ ├── capabilities-card.tsx
│ │ ├── clipboard-card.tsx
│ │ ├── haptics-card.tsx
│ │ ├── host-actions-card.tsx
│ │ └── launch-params-card.tsx
│ ├── navigation/
│ │ └── components/
│ │ ├── tab-bar.tsx
│ │ └── native-back-button.tsx
│ └── debug/
│ └── eruda.tsx
├── lib/
│ ├── api/
│ │ ├── client.ts
│ │ └── with-auth.ts
│ ├── db/
│ │ ├── index.ts
│ │ └── schema.ts
│ └── env.ts
├── drizzle/
├── scripts/
│ └── migrate.ts
├── instrumentation.ts
├── drizzle.config.ts
├── next.config.ts
├── docker-compose.yml
├── .env.example
└── package.jsonConfigure Environment Variables
Copy the template and fill in your values:
cp .env.example .env| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL connection string |
WEBHOOK_PUBLIC_KEY | Ed25519 public key (hex, 64 chars) for verifying payment webhook signatures |
ALIEN_AUDIENCE | Expected JWT aud claim — your provider address from the Developer Portal |
ALIEN_JWKS_URL | JWKS endpoint for verifying SSO access tokens (optional; defaults to https://sso.alien-api.com/oauth/jwks) |
RUN_MIGRATIONS | Set to true to run DB migrations on server start (optional; off by default) |
NEXT_PUBLIC_RECIPIENT_ADDRESS | Solana wallet for USDC/SOL payments |
NEXT_PUBLIC_ALIEN_RECIPIENT_ADDRESS | Alien provider address for ALIEN token payments |
Default .env for local development:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/miniapp
WEBHOOK_PUBLIC_KEY=<your-webhook-public-key>
ALIEN_AUDIENCE=<your-provider-address>
ALIEN_JWKS_URL=https://sso.alien-api.com/oauth/jwks
NEXT_PUBLIC_RECIPIENT_ADDRESS=<your-solana-wallet>
NEXT_PUBLIC_ALIEN_RECIPIENT_ADDRESS=<your-alien-provider-address>
NODE_ENV=developmentWhere to get the values
NEXT_PUBLIC_RECIPIENT_ADDRESS— any Solana wallet address you control. This is where USDC and SOL payments will be sent.NEXT_PUBLIC_ALIEN_RECIPIENT_ADDRESS— your provider address from the Developer Portal . Found on the Mini Apps and Webhooks pages. ALIEN token payments always go to your provider address.ALIEN_AUDIENCE— the expectedaudclaim of incoming auth tokens. This is the same provider address as above.WEBHOOK_PUBLIC_KEY— the Ed25519 public key (hex-encoded) provided by the Developer Portal when you register a webhook. Copy it immediately after creation — it is only shown once.ALIEN_JWKS_URL— the JWKS endpoint used to verify SSO access tokens. The default targets Alien production SSO (https://sso.alien-api.com/oauth/jwks); override it for other environments.
Start the Database
docker compose up -dRun Migrations
bun run db:migrateStart Development Server
bun run devOpen http://localhost:3000 to see the app.
What’s Included
| Package | Purpose |
|---|---|
@alien-id/miniapps-react | React hooks and AlienProvider |
@alien-id/miniapps-auth-client | JWT verification for backend |
@alien-id/miniapps-bridge | Low-level bridge transport (and mock bridge) |
@alien-id/miniapps-contract | Shared protocol types (e.g. test scenarios) |
drizzle-orm | Type-safe database ORM |
next | React framework (v16) |
@tanstack/react-query | Data fetching and caching |
zod | Schema validation for API payloads |
tailwindcss | Utility-first CSS |
Database
PostgreSQL with Drizzle ORM. Local setup uses Docker
(docker-compose.yml).
Schema
Users (users):
| Column | Type | Description |
|---|---|---|
id | UUID | Auto-generated primary key |
alienId | TEXT (unique) | User’s Alien ID from JWT sub |
createdAt | TIMESTAMP | Set on first auth |
updatedAt | TIMESTAMP | Updated on each auth |
Payment Intents (payment_intents):
| Column | Type | Description |
|---|---|---|
id | UUID | Auto-generated primary key |
invoice | TEXT (unique) | Invoice identifier (inv-<uuid>) |
senderAlienId | TEXT | Payer’s Alien ID |
recipientAddress | TEXT | Recipient wallet/provider address |
amount | TEXT | Amount in smallest units |
token | TEXT | Token type (USDC / ALIEN) |
network | TEXT | Network (solana / alien) |
productId | TEXT | Product identifier |
status | TEXT | pending / completed / failed |
createdAt | TIMESTAMP | Set on creation |
Transactions (transactions):
| Column | Type | Description |
|---|---|---|
id | UUID | Auto-generated primary key |
senderAlienId | TEXT | Payer’s Alien ID |
recipientAddress | TEXT | Recipient wallet/provider address |
txHash | TEXT | On-chain transaction hash |
status | TEXT | paid / failed |
amount | TEXT | Payment amount |
token | TEXT | Token type |
network | TEXT | Network |
invoice | TEXT | Associated invoice |
test | TEXT | "true" for test payments; NULL for real ones |
payload | JSONB | Full webhook payload for audit |
createdAt | TIMESTAMP | Set on creation |
Commands
bun run db:generate # Generate migration from schema
bun run db:migrate # Apply pending migrations
bun run db:push # Push schema directly (dev only)
bun run db:studio # Open Drizzle Studio GUITo run migrations automatically on server start, set
RUN_MIGRATIONS=true (handled by the instrumentation.ts hook).
Disabled by default.
API Endpoints
GET /api/me
Returns the authenticated user. Requires Bearer token.
{
"id": "uuid",
"alienId": "user-alien-id",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}POST /api/invoices
Creates a payment intent. Requires Bearer token.
Request body: only productId is accepted (it must match an id
in the product catalog). The recipient, amount, token, and network
are derived server-side from the catalog entry.
{
"productId": "usdc-diamonds-10"
}Response:
{
"invoice": "inv-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"id": "uuid",
"recipient": "wallet-or-provider-address",
"amount": "10000",
"token": "USDC",
"network": "solana",
"item": {
"title": "10 Diamonds",
"iconUrl": "https://.../diamond.png",
"quantity": 10
}
}test is present only for test-scenario products.
GET /api/transactions
Returns the authenticated user’s transaction history. Requires Bearer token.
POST /api/webhooks/payment
Receives payment status updates from the Alien platform,
implementing the version 3
webhook contract: Ed25519
signature verification against WEBHOOK_PUBLIC_KEY, an
X-Webhook-Version check, and payload cross-validation against the
stored payment intent. Re-delivered webhooks for settled intents are
acknowledged without reprocessing.
Deployment
The boilerplate is designed to deploy on Vercel — any Next.js-capable host works:
- Push your code to GitHub and import the repository on Vercel
- Add a PostgreSQL database (Vercel Postgres, Neon, Supabase, or
any external provider) and set
DATABASE_URL - Register a webhook in the
Developer Portal pointing to
https://<your-domain>/api/webhooks/payment - Set
WEBHOOK_PUBLIC_KEY,ALIEN_AUDIENCE,NEXT_PUBLIC_RECIPIENT_ADDRESS, andNEXT_PUBLIC_ALIEN_RECIPIENT_ADDRESS - Either run
bun run db:migratemanually or setRUN_MIGRATIONS=trueto migrate on server start - Deploy
Next Steps
- Create Mini App — Register in the Dev Portal
- Testing — Test locally and in the Alien app
- Authentication — Learn how auth works
- Payments — Accept payments