This page follows the framework-first happy path with Next.js. You end with a normal Next.js app that uses Agentuity for service clients, local environment wiring, and deploy packaging. The same create flow works for the five create-supported frameworks: Next.js, Nuxt, SvelteKit, Astro, and Hono. For React Router, Vite + React, and TanStack Start, start with the framework CLI and then import the app.
1. Create the Project
npm create agentuity -- \
--name my-app \
--framework nextjs \
--package-manager npm
cd my-appThe scaffold runs create-next-app, then layers on:
@agentuity/clias a devDependency@agentuity/aigatewayandswras dependencies- A working translation page at
src/app/page.tsx - An API route at
src/app/api/translate/route.tsthat usesAIGatewayClient deploy: agentuity deployinpackage.jsonagentuity.jsonwith the registered project's metadata.envwith the project'sAGENTUITY_SDK_KEY
Expected result: the command exits with a my-app/ directory that contains the framework files, agentuity.json, .env, and the translation route. If it stops before those files exist, rerun the command from an empty directory. If authentication fails before the project is created, run npx @agentuity/cli auth login, then create the project again.
2. Run It Locally
npx agentuity devnpx runs the local CLI from devDependencies. The CLI runs next dev as a child process and patches AGENTUITY_SDK_KEY plus service environment values into its env, so @agentuity/aigateway can call the gateway for the project. Open the URL Next.js prints (typically http://localhost:3000) and try a translation.
You can also call the API route directly:
curl -X POST http://localhost:3000/api/translate \
-H "Content-Type: application/json" \
-d '{"text":"Hello from Agentuity","toLanguage":"French"}'The response includes the translation, token count, model, and target language.
If the dev server starts but the route fails, read the route response and terminal error first. 401 or missing-key errors usually mean the command is not running from the registered project root or AGENTUITY_SDK_KEY is missing from the dev process. If the port is already in use, run npx agentuity dev --port 8080 or use the port your framework prints.
3. Make an Edit
Open src/app/page.tsx and add a language to the picker:
const LANGUAGES = ['Spanish', 'French', 'German', 'Chinese', 'Japanese'] as const;Save the file. Next.js hot-reloads, the new option appears in the dropdown, and the route accepts it without any other change.
4. Add a Service Client
Service clients work in any framework route or script. Add key-value storage without touching the router or runtime:
npm install @agentuity/keyvalueimport { KeyValueClient } from '@agentuity/keyvalue';
const kv = new KeyValueClient();
await kv.set('analytics', 'last-translation-at', { at: new Date().toISOString() });The client reads AGENTUITY_SDK_KEY from process env. agentuity dev supplies that key for local runs, and registered deployed apps receive it as a project secret.
See Services for queues, vector storage, email, schedules, sandbox execution, and the rest.
5. Deploy
npm run deployThe deploy script runs agentuity deploy, which:
- Detects the framework from
package.jsonand config files - Runs the framework's build, then packages the output into
.agentuity/ - Encrypts the bundle, uploads it, and starts the deployment
The CLI prints both the deployment-specific URL and the latest deployment URL. Visit either in a browser, or check app.agentuity.com for logs and resource settings.
Verify the Path
| Stage | Success looks like | If it fails |
|---|---|---|
| Create | agentuity.json, .env, and the framework route exist in my-app/ | Start from an empty directory, then rerun the create command |
| Local route | The page translates text, and the curl request returns JSON | Check the terminal error, project root, port, and AGENTUITY_SDK_KEY |
| Service client | npm install @agentuity/keyvalue installs, and server code imports KeyValueClient | Keep the client in server-side code, not browser components |
| Deploy | The CLI prints deployment URLs after the framework build | Fix the framework build error first; deploy packages that build output |
Next Steps
- Project Structure: the file map for each framework
- App Configuration: scripts,
agentuity.json, env vars, and service clients - Frameworks: per-framework setup, route patterns, and deploy notes
- Local Development: how
agentuity devresolves the SDK key, env files, and gateway routing