---
url: /blog/2026/v0.7.4.md
description: >-
  v0.7.4 makes a sidecar a block of any source folder, next to frontend and
  backend, with its files in sidecar/, added in kosmo.config.ts or with kosmo
  folder --sidecar. Sidecar tests load into Vitest, and testing is opt-in for
  every folder.
---

## A sidecar was a folder of its own

A sidecar has been its own kind of source folder:
`kosmo sidecar` created it, its `kosmo.config.ts` named an `entry` and a `run`,
and the two files sat at the folder root.

Putting one beside a web app worked, but only just,
and the docs talked you out of it.

## Now it is a block

A sidecar is a block of a source folder now, just like `frontend` and `backend`.
Any folder can have one, beside pages and an API or on its own:

```ts [src/app/kosmo.config.ts]
export default defineConfig({
  frontend: {
    // ...
  },
  backend: {
    // ...
  },
  sidecar: { // [!code ++:3]
    serve: false,
  },
});
```

Its files live in the folder's `sidecar/` directory,
the way pages live in `pages/` and API routes in `api/`:

```txt
src/app/
├── api/
├── pages/
└── sidecar/
    ├── entry.ts          -> the service: defineService({ start, teardown })
    └── run.ts            -> the runner: starts it, stops it on a signal
```

The block names no files any more.
`sidecar/entry.ts` and `sidecar/run.ts` are the convention, seeded when missing,
like `api/app.ts` for a backend or `entry/client.ts` for a frontend.
That leaves the block with options only: `serve`, `test` and `viteConfig`.

`serve` is required now, so every sidecar says whether the dev server runs it.

The build already wrote a sidecar into `dist/<folder>/sidecar/`,
so the source and the output now have the same shape.

Whether a worker belongs in the app's folder, or in one of its own, is a judgement call now.
[Sidecars ›](/sidecar/intro#beside-a-web-app-or-on-its-own) weighs it up.

## kosmo sidecar is gone

With a sidecar being a block, adding one is a line in `kosmo.config.ts`,
not a command of its own:

```ts [src/app/kosmo.config.ts]
export default defineConfig({
  // ...
  sidecar: { // [!code ++:3]
    serve: false,
  },
});
```

The next start seeds `sidecar/entry.ts` and `sidecar/run.ts`.

When creating a folder, `kosmo folder` can add the block for you:
it asks about a sidecar in its dialog, after the frontend and the backend, or takes `--sidecar`.
That is also the way to a sidecar on its own, in a folder with neither side:

```sh
pnpm folder --name mailer --sidecar
```

`--sidecar` takes no value. Leave it out and the dialog asks about a sidecar,
or, with no terminal to ask in, the folder gets none.

`create kosmo` does the same for a project's first folder:
it takes `--sidecar`, and asks about a sidecar when the flag is missing.

## No more --no-\* flags

`--no-frontend` and `--no-backend` are gone.
`--frontend`, `--backend` and `--sidecar` are each optional now,
and at least one is required.

In a terminal, the dialog asks only for the ones you leave out.
With no terminal to ask in, the folder goes without them:

```sh
pnpm folder --name svc    --backend hono
pnpm folder --name docs   --frontend mdx
pnpm folder --name mailer --sidecar
```

Giving or choosing none of them is an error.

`create kosmo` works the same way.

## Sidecars get tests

`vitest.config.ts` loads every source folder with testing enabled as a Vitest project:
`<folder>:api` for the backend, `<folder>:pages` for the frontend.

Sidecars were not on that list,
so a test beside a queue consumer or a mail listener never ran.

Now a sidecar can turn its tests on:

```ts [src/mailer/kosmo.config.ts]
export default defineConfig({
  sidecar: {
    serve: false,
    test: true, // [!code hl]
  },
});
```

Every `*.test.ts` and `*.spec.ts` file under `sidecar/` is then loaded, at any depth,
as a project of its own named `mailer:sidecar`.

Not just `index.{test,spec}.ts`, as on frontend and backend, where tests follow the routes.
A sidecar has no routes to follow, so `service.test.ts` and `smtp/parser.spec.ts` count alike.

And since they stay within `sidecar/`, as frontend tests stay within `pages/`,
a folder with all three blocks has each test file in exactly one project.

Nothing is seeded, so the tests are yours to write.
There is no harness to go through either: the entry is an ordinary module,
so a test starts it the way the runner does, and stops it the same way.

To run just those:

```sh
pnpm test --project mailer:sidecar
```

[Details ›](/sidecar/testing)

## Testing is opt-in

`frontend.test` and `backend.test` seed a starter `index.test.ts` beside every route.
That is a file in your source folder for every page and every endpoint,
and the scaffolder used to write `test: true` into each new folder's config,
so you got them without asking.

Now new folders are scaffolded without it, and testing is off until you turn it on.
The same goes for sidecars, which is why `sidecar.test` is off by default too.

```ts [kosmo.config.ts]
export default defineConfig({
  frontend: {
    // ...
    test: true, // [!code hl]
  },
  backend: {
    // ...
    test: true, // [!code hl]
  },
});
```

Or `test: { seed: false }`, to get the harness without the seeded files.

## .spec.ts loads too

Frontend and backend tests used to load only as `index.test.ts`.
Now `index.spec.ts` loads as well, so either naming habit works.

Seeding still writes `index.test.ts`.
To seed under another name, set [seed.name](/frontend/testing#name-and-path);
once it is set, that name is also the only one that loads.

## Upgrading

### Sidecar folders

Move the two files into `sidecar/`, drop `entry` and `run` from the block,
and give it `serve` if it has none:

```txt
src/mailer/entry.ts  ->  src/mailer/sidecar/entry.ts
src/mailer/run.ts    ->  src/mailer/sidecar/run.ts
```

```ts [src/mailer/kosmo.config.ts]
export default defineConfig({
  sidecar: {
    entry: "./entry.ts", // [!code --]
    run: "./run.ts", // [!code --]
    serve: false,
  },
});
```

Move them rather than delete:
a missing file is seeded anew, and your code would be gone with the old one.

### Scripts

`pnpm sidecar` becomes `pnpm folder`,
and the `sidecar` script in `package.json` can go.

Drop `--no-frontend` and `--no-backend` wherever a script passes them:
`pnpm folder --name svc --no-frontend --backend hono`
becomes `pnpm folder --name svc --backend hono`.

### Tests

Nothing to change.
Existing folders keep the `test: true` the scaffolder wrote into their config,
and their tests run as before.
Sidecars without `test` stay out of Vitest, as before too.
