# Frameworks

acdev doesn't ask you to change your framework's config. At build time it recognizes the framework from your dependencies, runs **the framework's own build**, and puts the output into the package. The first match wins:

| Dependency | Build command | Output |
| --- | --- | --- |
| `next` | `next build` (standalone) | `.next/standalone` as the backend; static `out/` with `output: 'export'` |
| `nuxt` (or `nuxt3`) | `nuxt build` (`node-server` preset) | `.output/server/index.mjs` as the backend, `.output/public` |
| `@sveltejs/kit` | `vite build` | The server is wrapped as the backend; `client` is the static assets |
| `astro` | `astro build` | `dist/`; a backend if `dist/server/entry.mjs` exists |
| `@react-router/dev` / `@remix-run/dev` | `react-router build` / `remix vite:build` | A backend if `build/server/index.js` exists |
| `@angular/core` + `@angular/cli` | `ng build --configuration production --base-href /` | `dist/**/browser`; a backend if `server/server.mjs` exists |
| `vite` | Calls the project's Vite `build()` in process, reading its `vite.config` | Static pages |
| `react-scripts` | `react-scripts build` | `build/` |
| A `build` script in `package.json` | `bun --bun run build` when acdev runs on Bun, otherwise `<pm> run build` | The first of `dist` / `build` / `out` / `www` / `.output/public` that contains HTML |

For server-rendered frameworks, pages are generated by the backend, and the manifest's `entry` is `/app/<id>/` (ending in `/`).

If there's no `node_modules`, acdev runs `<pm> install` first.

To start a project with one of these frameworks, `acdev new --template` has `next`, `nuxt`, `sveltekit` and `astro`, and the Vite templates `react`, `vue`, `svelte`, `solid`, `preact` and `vanilla`; see [First app](https://docs.dopame.ai/start/first-app.md#create).

## Saving in acdev dev

`acdev dev` runs the same production build after every save and **reloads the whole page**, unless the build changed only stylesheets and scripts that the runtime can swap into the running page (see [Reloading](https://docs.dopame.ai/guide/dev.md#reloading)); it does not use the framework dev server or hot module replacement (HMR). Across the reload, acdev restores form values, scroll position, focus and text selection, but **component state is lost**: a React or Preact `useState` counter, Vue `ref`s, Svelte and Solid signals, and any other value held only in memory start over. Keep state you want to survive a reload in `localStorage` or IndexedDB. See [Reloading](https://docs.dopame.ai/guide/dev.md#reloading).

Pages made by `acdev new --template react` (and the other Vite templates) say "save to reload the page" where Vite's own templates say "save to test HMR".

## Detection

Use `framework` in `acde.config.jsonc`:

- `auto` (default): detect using the table above.
- `next`, `nuxt`, `sveltekit`, `astro`, `react-router`, `remix`, `angular`, `vite`, `cra`, `script`: use this one.
- `none`: no framework; acdev bundles `entry` itself.

When `entry` is set, acdev doesn't pick up Vite (the built-in templates depend on Vite only so acdev can bundle with it). To build with Vite, remove `entry` or set `"framework": "vite"`.

## Without a framework

When no framework is recognized (or with `"framework": "none"`), acdev bundles from `entry`:

- HTML entry: `base` is `/app/<id>/`, `acde:*` imports stay external, `NODE_ENV` is `"production"`, and `import.meta.env` works as in Vite (including `VITE_*` variables).
- Module entry: bundled into `<name>.js` with its exports kept; the default export is a `WindowApp`.

On Bun it uses `Bun.build`; on Node.js it uses the project's Vite (if it's missing, you're told to `add it with <pm> add -D vite`). The rules are the same on both.

## Vite plugin

When acdev builds a project with Vite it adds its own plugin: `acde:*` imports stay external. The plugin comes with acdev, not with the SDK, so a project's own `vite.config` cannot import it; a plain `vite dev` in a regular browser doesn't know `acde:` modules (see below).

## acde: modules

If the same code needs to run both in a browser and in acdev, import the module dynamically; the import rejects where the module isn't available:

```js
const fs = await import('acde:fs').then((m) => m.default, () => null)
if (fs) console.log(await fs.roots())
```
