From 7bc6c74552a56b4ec2bcebf1e7a0732c3535a6c5 Mon Sep 17 00:00:00 2001 From: pulgueta Date: Tue, 13 Feb 2024 16:36:38 -0500 Subject: [PATCH] Cached current user function to avoid longer page loads --- lib/auth/currentUser.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/auth/currentUser.ts b/lib/auth/currentUser.ts index 8bd4e40..c208663 100644 --- a/lib/auth/currentUser.ts +++ b/lib/auth/currentUser.ts @@ -1,11 +1,13 @@ +import { cache } from 'react'; + import { auth } from './auth'; -export const currentUser = async () => { +export const currentUser = cache(async () => { const user = await auth(); if (!user) return; return user.user; -}; +}); export type CurrentUser = Awaited>;