You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
644 B
TypeScript
23 lines
644 B
TypeScript
import type { PageContextServer } from "vike/types";
|
|
|
|
// This hook is called upon new incoming HTTP requests
|
|
export async function onCreatePageContext(pageContext: PageContextServer) {
|
|
// // Select the properties you want to make available everywhere
|
|
pageContext.user = {
|
|
id: pageContext.session?.user?.id,
|
|
email: pageContext.session?.user?.email,
|
|
};
|
|
}
|
|
|
|
declare global {
|
|
namespace Vike {
|
|
// We extend PageContext instead of PageContextServer because user is passed to the client
|
|
interface PageContext {
|
|
user?: {
|
|
id: string | null | undefined;
|
|
email: string | null | undefined;
|
|
};
|
|
}
|
|
}
|
|
}
|