Project Structure

View as Markdown

The basic template starts with this structure:

my-app/
├── public/
│   └── favicon.svg
├── src/
│   ├── routes/
│   │   ├── _layout.tsx
│   │   ├── index.tsx
│   │   └── users/
│   │       └── [id].tsx
│   ├── main.tsx
│   └── neutron-env.d.ts
├── neutron.config.ts
├── package.json
├── tsconfig.json
└── vite.config.ts

src/routes

Files define URLs:

  • index.tsx maps to the directory root.
  • [id].tsx creates a dynamic segment.
  • [...slug].tsx creates a catch-all segment.
  • _layout.tsx wraps routes in its directory and all child directories.

A route can export a component, a loader, an action, metadata through head, middleware, and route configuration. Import framework APIs from @neutron-build/core.

src/main.tsx

This is the browser entry point. The generated file registers the virtual route manifest and initializes Neutron. Most applications do not need to change it.

neutron.config.ts

The scaffold records the rendering runtime here:

import { defineConfig } from "@neutron-build/core";

export default defineConfig({
  runtime: "preact",
});

Deployment presets are selected by the CLI, for example neutron-ts build --preset vercel.

Next