Latest Results
feat(session): add `session: false` to opt out of session support
Adds a `session: false` config option that opts a project out of session
support entirely, and tree-shakes the session runtime (`AstroSession` +
`unstorage`) out of the SSR bundle for any project where no session driver
is wired.
- `session: false` is accepted by `SessionSchema` and threaded through so
adapters skip auto-wiring their default driver (`@astrojs/cloudflare`,
`@astrojs/netlify`, `@astrojs/node`).
- When no driver will be present at request time — `session: false`, no
`session` config at all, or a `session` object without a driver —
`Astro.session` (and `context.session`) is `undefined`, matching its
existing `AstroSession | undefined` type. This keeps the established
`if (Astro.session)` feature-detection contract instead of throwing.
- A new `astro:session-provider` Vite plugin swaps Astro's own
`core/session/provider.js` for a runtime-free `provider-disabled.js`
stub whenever no driver is wired, so Rollup drops `runtime.js` and
`unstorage` from the bundle. Adapters wire their default driver during
`astro:config:setup` (before `createVite`), so `config.session?.driver`
reflects the final decision by resolve time — the same signal the
driver virtual module uses. The swap is behavior-preserving: the real
provider already resolves the session to `undefined` when no driver
factory exists, so this only drops now-dead code.
```js title="astro.config.mjs"
import { defineConfig } from 'astro/config';
export default defineConfig({
session: false,
});
```
Projects that already wire a session driver see no behavior change; the
runtime is retained whenever a driver is configured. Latest Branches
0%
0%
thelazylamaGit:astro-css-fix -1%
© 2026 CodSpeed Technology