Skip to content

Hooks.js handle function not triggered on every request #4544

@stausmar

Description

@stausmar

Describe the bug

Due to the documentation, the hooks.js handle function should run on every request. See: https://kit.svelte.dev/docs/hooks#handle.

For me, it seems that the hooks.js is not called on client side navigation. I'm not sure if this is really a bug, but I couldn't find anything else in the documentation. If it's not a bug, it would be great if there is at least a note in the docs that it's not executed on client-side navigation.

Reproduction

Create a new project, choose the demo-app and put a console.log(event.url.pathname) in the existing hooks.js handle function.

npm init svelte@next my-app
cd my-app
npm install
npm run dev

Navigate between the different pages using the navigation bar of the application. Observe the console output and see that the navigations are not logged. This means, the hooks.js handle function is not executed on every request as stated in the docs.

Logs

No response

System Info

System:
    OS: Linux 5.15 Manjaro Linux
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 802.46 MB / 7.65 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 17.7.1 - /usr/bin/node
    npm: 8.5.4 - /usr/bin/npm
  Browsers:
    Chromium: 100.0.4896.75
    Firefox: 99.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.34 
    @sveltejs/kit: next => 1.0.0-next.307 
    svelte: ^3.46.0 => 3.46.6

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions