Update Next.js version and improve session handling

Next.js version has been upgraded from 14.2.0-canary.58 to 14.2.0-canary.60 for performance and stability improvements. Additionally, account session handling has been improved by fetching the session data during server-side processing and passing it to various components, thus optimizing the user experience.
This commit is contained in:
giancarlo
2024-04-06 14:34:05 +08:00
parent 9303e8f5dd
commit 67e9c8b676
8 changed files with 88 additions and 57 deletions

View File

@@ -3,16 +3,20 @@ import { cache } from 'react';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
export const loadUserWorkspace = cache(async () => {
const accounts = await loadUserAccounts();
const client = getSupabaseServerComponentClient();
const accounts = await loadUserAccounts(client);
const { data } = await client.auth.getSession();
return {
accounts,
session: data.session,
};
});
async function loadUserAccounts() {
const client = getSupabaseServerComponentClient();
async function loadUserAccounts(
client: ReturnType<typeof getSupabaseServerComponentClient>,
) {
const { data: accounts, error } = await client
.from('user_accounts')
.select(`name, slug, picture_url`);