Solution here
Describe the bug
Hi,
Using init in a hooks.client.ts file would work as intended but not in production (Vercel in my case)
Reproduction
- Create a
hooks.client.ts with init that does some logic
- Make sure the logic works in development environment
- Host the project in Vercel
- Check if the logic is working
Logs
System Info
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
npmPackages:
@sveltejs/adapter-auto: ^3.3.1 => 3.3.1
@sveltejs/adapter-vercel: ^5.4.6 => 5.5.3
@sveltejs/kit: ^2.7.3 => 2.16.0
@sveltejs/vite-plugin-svelte: 4.0.0 => 4.0.0
svelte: ^5.1.2 => 5.19.0
vite: ^5.0.0 => 5.4.11
Severity
serious, but I can work around it
Additional Information
According to the docs:
This function runs once, when the server is created or the app starts in the browser, and is a useful place to do asynchronous work such as initializing a database connection.
Does this mean that the init function in a vercel instance runs ONLY when the server has started? But what about the second part of the statement? Am I misunderstanding the docs here?
Solution here
Describe the bug
Hi,
Using
initin ahooks.client.tsfile would work as intended but not in production (Vercel in my case)Reproduction
hooks.client.tswithinitthat does some logicLogs
System Info
System: OS: Windows 10 10.0.19045 Binaries: Node: 20.9.0 - C:\Program Files\nodejs\node.EXE npmPackages: @sveltejs/adapter-auto: ^3.3.1 => 3.3.1 @sveltejs/adapter-vercel: ^5.4.6 => 5.5.3 @sveltejs/kit: ^2.7.3 => 2.16.0 @sveltejs/vite-plugin-svelte: 4.0.0 => 4.0.0 svelte: ^5.1.2 => 5.19.0 vite: ^5.0.0 => 5.4.11Severity
serious, but I can work around it
Additional Information
According to the docs:
Does this mean that the init function in a vercel instance runs ONLY when the server has started? But what about the second part of the statement? Am I misunderstanding the docs here?