As per the documentation of svelte-kit handle in hooks
This function runs every time SvelteKit receives a request — whether that happens while the app is running, or during prerendering — and determines the response.
This sample repository contains a new project created using the following steps
npm init svelte@next
pnpm i
When I run the application usin pnpm dev
or pnpm build && pnpm preview
. The output of the logged calls is not consistent with the pages visited.
For example I started the application and browser was already on http://localhost:3000/one. And the output logges was
pnpm preview
> [email protected] preview /Users/Jerry/Code/Vikalp/kit-hooks
> svelte-kit preview
SvelteKit v1.0.0-next.267
local: http://localhost:3000
network: not exposed
Use --host to expose server to other devices on this network
handle /one
Next I clicked on each of the links (home, one, two), but there was no change in the output.
Repeated the same actions after stopping and restarting the application using pnpm preview
and pnpm dev
and the only time handle seems to be called is whn I explicitly refresh the browser.
pnpm dev
> [email protected] dev /Users/Jerry/Code/Vikalp/kit-hooks
> svelte-kit dev
SvelteKit v1.0.0-next.267
local: http://localhost:3000
network: not exposed
Use --host to expose server to other devices on this network
^C% `
```text
pnpm dev
> [email protected] dev /Users/Jerry/Code/Vikalp/kit-hooks
> svelte-kit dev
SvelteKit v1.0.0-next.267
local: http://localhost:3000
network: not exposed
Use --host to expose server to other devices on this network
handle /two