Getting started
Three ways to a working terminal on http://localhost. All of them end with the same files: a Test key in .env.local, one route on your server and <Terminal> on a page.
Start from | Run | Best when |
|---|---|---|
Nothing |
| You want a new app to build on |
Your own project folder |
| You already have an app, or a coding agent is working in it |
Your own project folder, by hand |
| You want to see every step |
You need a Chartnaut account. Any plan works, Free included. Each of these makes or picks a project: the Chartnaut side of your app, with its keys and sites. A project starts in Test: localhost is allowed and only you and your team can sign in. Test usage counts against nothing. Each project counts toward your plan's projects.
A new app
npm create @chartnaut/app my-appYour browser opens on Chartnaut. Check the code matches the one in your terminal, then approve. The approval asks for one extra permission: creating developer projects and Test keys.
It creates a project for you (or pass
--app <slug>to use one you have), writes its Test key intomy-app/.env.localand copies in the template.It installs the packages and prints what to run next.
cd my-app
npm run devOpen http://localhost:3000. The terminal asks you to sign in with Chartnaut the first time; approve, and it opens.
Option | What it does |
|---|---|
| Next.js with the app router (the default) |
| Vite and React on the page, Express on the server. Vite sends |
| Use a project you already have instead of creating one |
| The new project's name |
| Print the sign-in link instead of opening it |
| Skip |
The sign-in key it uses is short-lived and is revoked when it finishes. With CHARTNAUT_TOKEN set in your shell it uses that key and leaves it alone.
An existing app, with the CLI
Install the CLI and run this in your project folder:
chartnaut init --projectIt does each of these, and tells you what it did:
Signs you in through your browser with the permission to create projects and Test keys. If you were signed in without it, the new sign-in replaces the old one.
Picks your project, or creates one. Pass a slug (
chartnaut init --project acme-desk-k3p9) or--name "Acme Desk"to skip the question.Makes a Test key and writes it to
.env.localasCHARTNAUT_SECRET_KEY, withCHARTNAUT_APPset to the project's slug. The key is never printed..env.localis added to.gitignoreif it isn't there.Checks localhost is allowed. In Test every
http://localhostandhttp://127.0.0.1port is, with nothing to add.Writes the project's slug into
chartnaut.json, which links this folder to the project. Adds a short guide for coding agents toAGENTS.mdandCLAUDE.md(betweenchartnaut-app:beginandchartnaut-app:end), and a skill at.claude/skills/chartnaut-sdk/SKILL.md.In an empty folder, copies in a template.
Runs
chartnaut project check.
Option | What it does |
|---|---|
| Create a project with this name |
| The template to copy in. Default: |
| Your dev server's port. Default 3000 for |
| Print the sign-in link instead of opening it |
| Skip |
Other project commands:
Command | What it does |
|---|---|
| Your projects |
| A new project |
| A new Test key, written to |
| The checklist below |
| Sign in with the permission to create projects and Test keys |
The CLI and the MCP server never make Live keys. Those are made in Developers, in your browser.
By hand
Install the packages
npm install @chartnaut/charts @chartnaut/nodeAdd your Test key
Open the menu under your name, then Developers, and Create project. Copy its Test key (it is shown once) into .env.local:
CHARTNAUT_SECRET_KEY=cn_partner_test_...Add the route
<Terminal> asks your server for its address. In Next.js:
// app/api/chartnaut/frame/route.ts
import { frameRoute } from "@chartnaut/node";
export const GET = frameRoute({
getUser: async () => (await auth())?.user.id ?? null,
whenNotLinked: { link: { scopes: ["frame:instant", "frame:live", "terminal:read", "terminal:write"] } },
frameOptions: { mode: "live" },
});With Express:
// server.ts
import express from "express";
import { frameRouteExpress } from "@chartnaut/node";
const app = express();
app.get(
"/api/chartnaut/frame",
frameRouteExpress({
getUser: (req) => req.user?.id ?? null, // your own sign-in, e.g. Passport
whenNotLinked: { link: { scopes: ["frame:instant", "frame:live", "terminal:read", "terminal:write"] } },
frameOptions: { mode: "live" },
}),
);
app.listen(3001);frameOptions says what the terminal opens. { mode: "live" } is live charts, which needs frame:live in the scopes. { session: "ses_…" } opens a backtest your server made with cn.sessions.create. With neither, the terminal waits for a backtest and shows no chart. To pick per page, read it from the request: frameOptions: (req) => ({ session: new URL(req.url, "http://localhost").searchParams.get("session") ?? undefined }).
Put the terminal on a page
<Terminal> fills its parent, so give the parent a height:
"use client";
import { Terminal } from "@chartnaut/charts/react";
export default function TradePage() {
return <Terminal style={{ height: "100vh" }} charts={{ main: { symbol: "EURUSD", timeframe: "1h" } }} />;
}One terminal per page. For several charts, give it a layout instead of a second <Terminal>.
getUser returns your own id for the person signed in to your site, or null when nobody is (the route answers 401). Your id becomes ext:<id> on the API. Users covers linking and managed users.
Check it works
chartnaut project checkIt reads your project's quickstart and prints each step, done or not, with what to do next:
Step | Done when |
|---|---|
Test key made | The project has a Test key |
First frame | A terminal opened from your app on localhost or a Test site |
Your account linked | You signed in with your own Chartnaut account from your app in Test |
Developer terms accepted | Live only: you accepted the developer terms |
An https site added | Live only: your app's https address is on the project's Sites tab |
Live key made | Live only: you made a Live key |
The same checklist is the Quickstart on your project's Overview tab in Developers. Once the three Test steps are done, your app works on localhost. The Live steps happen in Developers: see Projects.
