Skip to navigation

AI App Template

A Next.js or Expo app with auth, a database, an agent, and a deploy

What it is

A full app scaffold for a product with users. It comes with authentication, a Postgres database, an AI agent your users can chat with, and a one-call deploy. Pick Next.js for a data-dense web app or Expo for mobile.

What it includes

PieceWhat it does
ScaffoldA Recursiv starter repo (nextjs or expo) created server side
AuthPasswordless plus OAuth sign-in, sessions, scoped per-user keys
DatabaseA Postgres database for your app data
AgentA model-agnostic agent (any supported model) with streaming chat
DeployA production deploy from the linked GitHub repo
IntegrationsOptional access to hundreds of data integrations as tools

How to start it

Scaffold a repo server side, create a project against it, then provision the rest. No local git or GitHub account required.

npm install @recursiv/sdk
export RECURSIV_API_KEY=sk_live_...
import { Recursiv } from '@recursiv/sdk';
const r = new Recursiv();
// 1. Scaffold a starter repo. Templates: 'nextjs' | 'expo'
const { data: repo } = await r.github.createFromTemplate({
template: 'nextjs',
name: 'my-ai-app',
});
// 2. Create the project linked to that repo
const { data: project } = await r.projects.create({
name: 'my-ai-app',
repo_url: repo.repo_url,
});
// 3. Provision a database
await r.databases.ensure({ project_id: project.id, name: 'main' });
// 4. Create the agent
const { data: agent } = await r.agents.create({
project_id: project.id,
name: 'App Assistant',
model: 'anthropic/claude-sonnet-4.6',
system_prompt: 'You help users get things done in this app. Be concise.',
});

Add auth

Sign users up and in, then mint a short-lived scoped key per session instead of shipping a long-lived key.

const session = await r.auth.signUp({ email, password });
const apiKey = await r.auth.createApiKey(
{ name: 'web-session', scopes: ['agents:read', 'agents:write', 'databases:read'] },
session.token,
);

Stream the agent to your UI

In Next.js and browsers, chatStream() yields { delta } chunks. In Expo, use chatStreamText().

for await (const chunk of r.agents.chatStream(agent.id, { message })) {
process.stdout.write(chunk.delta ?? '');
}

Deploy

Deploys build from the linked GitHub repo.

const { data: deployment } = await r.projects.deploy(project.id, {
branch: 'main',
type: 'production',
});
console.log(deployment.deployment_url);

Key SDK calls

  • r.github.createFromTemplate({ template, name }) - scaffold the repo
  • r.projects.create({ name, repo_url }) - the project
  • r.databases.ensure({ project_id, name }) - app database
  • r.auth.signUp(...), r.auth.signIn(...), r.auth.createApiKey(...) - auth and scoped keys
  • r.agents.create({ project_id, model, instructions }) - the agent
  • r.agents.chatStream(agentId, { message }) / r.agents.chatStreamText(...) - stream to your UI
  • r.projects.deploy(projectId, { branch, type }) - ship it

Next steps