Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview
On this page

Quickstart

Sign up from the terminal, define your first luna and call it over HTTP.

At the end of this page you have a luna running on Luna. It stores a list of items and returns them over HTTP. Every step runs in the terminal, in your project’s folder.

Start with your agent

Copy the prompt into your coding agent to have it follow this page for you.

Set up Luna in this project with your coding agent.

The prompt has your agent install the Luna skill first. The skill teaches an agent how to define, deploy and call lunas. To install it yourself, run this in your project folder:

npx skills add gabrieldrl/luna-skills

Prerequisites

  • The luna CLI. Run luna version to check that it is installed.
  • Node.js 22.18 or later.

Sign up

luna signup

Create an organisation

luna orgs create Acme

Create a project and an environment

luna projects create notes
luna env create dev

Define a luna

Install the TypeScript SDK.

npm install --install-links "$(luna sdk ts --path)"

Add a luna folder with these two files.

  • luna/
    • luna.config.ts
    • lunas/
      • list.ts
import { defineConfig } from "luna";

export default defineConfig({ lunas: "./lunas/list.ts" });
import { defineLuna, t, table } from "luna";

export const List = defineLuna({
  name: "List",
  visibility: "public",
  key: { id: t.string() },
  schema: {
    items: table({ id: t.id(), text: t.string() }),
  },
  handlers: (h) => ({
    add: h({ args: { text: t.string() } }, (ctx, { text }) => {
      ctx.db.items.insert({ text });
    }),
    all: h({ query: true }, (ctx) => ctx.db.items.find({ orderBy: "id" })),
  }),
});

Run it

luna dev

Call your luna

luna dev writes the app’s URL and publishable key to .env.local. In a second terminal, in the same folder, load them.

source .env.local

Add an item to the list named groceries.

curl -X POST "$LUNA_URL/List/groceries/add" \
  -H "luna-key: $LUNA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"milk"}'

Read the list back.

curl -X POST "$LUNA_URL/List/groceries/all" -H "luna-key: $LUNA_KEY"
[{"id":1,"text":"milk"}]

Next steps

  • Change a handler in luna/lunas/list.ts and save. luna dev deploys the change.
  • Run luna status to see the environment’s URL, its luna types and its calls.
  • Run luna deploy --env production when the app is ready for production.

Was this page helpful?