ChartnautDocs

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

npm create @chartnaut/app my-app

You want a new app to build on

Your own project folder

chartnaut init --project

You already have an app, or a coding agent is working in it

Your own project folder, by hand

npm install @chartnaut/charts @chartnaut/node

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-app
  1. Your 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.

  2. It creates a project for you (or pass --app <slug> to use one you have), writes its Test key into my-app/.env.local and copies in the template.

  3. It installs the packages and prints what to run next.

cd my-app
npm run dev

Open http://localhost:3000. The terminal asks you to sign in with Chartnaut the first time; approve, and it opens.

Option

What it does

--template next

Next.js with the app router (the default)

--template vite-express

Vite and React on the page, Express on the server. Vite sends /api to Express on port 3001

--app <slug>

Use a project you already have instead of creating one

--name <name>

The new project's name

--no-browser

Print the sign-in link instead of opening it

--no-install

Skip npm install

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 --project

It does each of these, and tells you what it did:

  1. 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.

  2. Picks your project, or creates one. Pass a slug (chartnaut init --project acme-desk-k3p9) or --name "Acme Desk" to skip the question.

  3. Makes a Test key and writes it to .env.local as CHARTNAUT_SECRET_KEY, with CHARTNAUT_APP set to the project's slug. The key is never printed. .env.local is added to .gitignore if it isn't there.

  4. Checks localhost is allowed. In Test every http://localhost and http://127.0.0.1 port is, with nothing to add.

  5. Writes the project's slug into chartnaut.json, which links this folder to the project. Adds a short guide for coding agents to AGENTS.md and CLAUDE.md (between chartnaut-app:begin and chartnaut-app:end), and a skill at .claude/skills/chartnaut-sdk/SKILL.md.

  6. In an empty folder, copies in a template.

  7. Runs chartnaut project check.

Option

What it does

--name <name>

Create a project with this name

--template <next|vite-express|none>

The template to copy in. Default: next in an empty folder, none otherwise

--port <port>

Your dev server's port. Default 3000 for next, 5173 for vite-express

--no-browser

Print the sign-in link instead of opening it

--no-check

Skip chartnaut project check at the end

Other project commands:

Command

What it does

chartnaut project list

Your projects

chartnaut project create <name>

A new project

chartnaut project key [slug]

A new Test key, written to .env.local in place of the old one

chartnaut project check [slug]

The checklist below

chartnaut login --projects

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/node

Add 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 check

It 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.