---
title: Develop with luna dev
description: Run your app in an environment of your own that redeploys on every save and prints its log lines as they come.
related:
  - /develop/manage-environments
  - /develop/deploy-an-app
  - /observe/read-logs
---

Luna runs your code in the cloud, so there is no local server to start while you work. `luna dev` keeps an environment of your own up to date with your folder: it deploys on every save and prints what your lunas log.

## Start luna dev

[`luna dev`](/cli/dev) deploys to the environment your folder uses. Make one with [`luna env create`](/cli/env) first, in the folder that holds your project.

```bash
luna env create dev
```

```bash
luna dev
```

`luna dev` finds the app in the folder where you run it: `luna.config.ts` there, or in its `luna` folder. Pass `--dir <PATH>` to run it from somewhere else.

On start it deploys once and prints the project, the environment, its URL, each luna type with its handlers, and the publishable key. If `.env.local` lacks `LUNA_URL` and `LUNA_KEY`, it writes them there, beside the `LUNA_PROJECT` and `LUNA_ENV` that `luna env create` wrote.

`luna dev` does not make an environment for you. In a folder that names none, it stops with `This folder has no environment. Run luna env create dev.`

## Save a change

Each time you save a `.ts`, `.js`, `.json` or `.py` file of the app, `luna dev` deploys again and prints one line with the new version number. Saves made close together go out as one deploy.

A save that changes what your code declares, such as a table or a handler, first prints the list of changes. A change that looks like a renamed column asks you to confirm in the terminal, as [`luna deploy`](/cli/deploy) does. Pass `--yes` to go ahead without being asked.

`luna dev` does not check types before it deploys, while `luna deploy` does. Rely on your editor, or run `npx tsc --noEmit`, to catch type errors as you work.

## Read the log lines

`luna dev` prints the environment's log lines as they arrive. Each line has the time, the level, the luna type, key and handler, then the text your code logged. Lines Luna writes itself are marked `luna`.

The lines come from every caller of the environment, not only from your terminal. Give each developer an environment of their own, as [Manage environments](/develop/manage-environments) shows.

Pass `--no-logs` to deploy on save without printing log lines. [Read logs](/observe/read-logs) covers `luna logs` and its filters.

## Fix a save that fails

A save that does not deploy prints a line starting with `✗` and the reason. The common reasons are code that fails to load, a declaration Luna refuses, and a dependency that cannot be sent.

Nothing is deployed in that case, so the environment keeps running the last version that worked. `luna dev` keeps watching, and the next save tries again. This holds for the first deploy too: fix the file, save, and it deploys.

## Mix TypeScript and Python

An app can name a TypeScript module and a Python module in its config, one for each language.

```ts luna/luna.config.ts
import { defineConfig } from "luna";

export default defineConfig({ lunas: ["./lunas/list.ts", "./lunas/wallet.py"] });
```

On each deploy, `luna dev` writes two files beside the config. `luna_gen.ts` types the Python luna types for TypeScript code, and `luna_gen.py` does the same for Python code. They are rewritten only when they change, so they do not set off another deploy. [Write lunas in Python](/lunas/write-lunas-in-python) shows how to call across languages with them.

Python luna types need CPython 3.12 or later. `luna dev` runs `python3`, or the interpreter that `LUNA_PYTHON` names.

## Stop luna dev

Press Ctrl-C in its terminal. The environment keeps the version you last deployed, and its lunas keep their data.

Run `luna dev` again later to carry on. It deploys the folder as it is now and starts watching again.

## Production is out of reach

`luna dev` never deploys to `production`. In a folder that uses production, it stops with `luna dev never runs in production`.

Switch the folder to another environment with `luna env use dev`, or make one with `luna env create`. To send a version to production, run `luna deploy --env production`, as [Deploy an app](/develop/deploy-an-app) shows.

## Next steps

- [Deploy an app](/develop/deploy-an-app) explains the checks and the confirmation a deploy goes through.
- [Manage environments](/develop/manage-environments) shows how to copy code and data into a new environment.
- [Store secrets](/develop/store-secrets) gives your environment the keys your code needs.
