# Writing compositions Compositions are **Solid JSX modules**. `dapi mount` compiles the module, runs it in the app, and renders every JSX element into an editable node in the document: no hidden DOM, no CSS, no layout pass. All positioning is explicit pixels. ```tsx export default function Project() { return ( {/* ... */} ); } ``` The module's default export is the project component. Solid's control flow (``, ``, …) and primitives (`createSignal`, `createMemo`, …) are available to *compose* the tree; the render is one-shot: after commit, the nodes belong to the document and signal changes no longer affect it. The update path is re-running the mount. **Dependencies:** `solid-js` and `@diffusionstudio/jsx` are provided by the app; everything else you import (npm packages, local files, JSON) is bundled by the CLI. Libraries must be browser-compatible. ## Roots and keys Every top-level element declares its identity with a `key`: - Mounting rebuilds the existing node carrying that key, or creates it. Entity id and canvas position are preserved across re-mounts. - Keyed nodes the render no longer produces are **deleted**; the mount owns its keyed roots. Unkeyed nodes (made by hand in the editor) are never touched. - Keys must be unique within a render. Give roots a `name` too: the key identifies, the name labels. The first rendered root becomes the active scene. New roots are auto-placed on the canvas near the viewport center; `` has no `x`/`y` because canvas arrangement is an editor concern, not part of the composition. ## Elements | Element | What it makes | | --- | --- | | `` | A scene; clips children to its `width`×`height`. Document root only; scenes don't nest. | | `` | Container with a transform; give it `fill` to draw a rectangle. | | `` | A filled rectangle. | | `` | Editable text. | | `