最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

svelte - How to trigger LayoutServerLoad on every navigation in SvelteKit? - Stack Overflow

programmeradmin3浏览0评论

I want to add a JWT verification/refresh in +layout.server.ts that is called on every navigation action.

I've got following code and noticed that the console.log() statement is only ran, when I reload the page with let's say F5 and not when navigating via anchor tags for example.

import type { LayoutServerLoad } from './$types';

export const load: LayoutServerLoad = async ({ cookies }) => {
    console.log("running layout on server");
};

How can I make it that the load function is called every time when navigating?

I want to add a JWT verification/refresh in +layout.server.ts that is called on every navigation action.

I've got following code and noticed that the console.log() statement is only ran, when I reload the page with let's say F5 and not when navigating via anchor tags for example.

import type { LayoutServerLoad } from './$types';

export const load: LayoutServerLoad = async ({ cookies }) => {
    console.log("running layout on server");
};

How can I make it that the load function is called every time when navigating?

Share Improve this question asked Mar 30 at 18:47 ReisMinerReisMiner 31 silver badge3 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

As far as I know, load functions only re-run if the parameters they depend on change (or if invalidateAll is invoked).

This logic is probably better suited to the handle hook.

发布评论

评论列表(0)

  1. 暂无评论