Skip to content

hooks.server.ts runs unexpectedly with disabled SSR #13735

Open
@FantixX

Description

@FantixX

Describe the bug

I am building an SPA and my root layout.ts contains export const ssr = false;. So far so good, +page.ts load functions now only load on the client. But I have a hooks.server.ts which is only supposed to run if +server.ts endpoints are hit. Strangely, it runs on every initial request to the page, which is weird, because with export const ssr = false; no requests should ever hit the server, at least that is what the docs suggest.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-grj3wfzf?file=src%2Fhooks.server.js

Logs

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^4.0.0 => 4.0.0 
    @sveltejs/kit: ^2.16.0 => 2.20.7 
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.3 
    svelte: ^5.25.0 => 5.28.2 
    vite: ^6.2.5 => 6.3.2 

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions