Next.js Supabase V3 (#463)
Version 3 of the kit: - Radix UI replaced with Base UI (using the Shadcn UI patterns) - next-intl replaces react-i18next - enhanceAction deprecated; usage moved to next-safe-action - main layout now wrapped with [locale] path segment - Teams only mode - Layout updates - Zod v4 - Next.js 16.2 - Typescript 6 - All other dependencies updated - Removed deprecated Edge CSRF - Dynamic Github Action runner
This commit is contained in:
committed by
GitHub
parent
4912e402a3
commit
7ebff31475
@@ -1,5 +1,4 @@
|
||||
import 'server-only';
|
||||
|
||||
import {
|
||||
AuthError,
|
||||
type EmailOtpType,
|
||||
@@ -306,16 +305,16 @@ function getAuthErrorMessage(params: { error: string; code?: string }) {
|
||||
// this error arises when the user tries to sign in with an expired email link
|
||||
if (params.code) {
|
||||
if (params.code === 'otp_expired') {
|
||||
return 'auth:errors.otp_expired';
|
||||
return 'auth.errors.otp_expired';
|
||||
}
|
||||
}
|
||||
|
||||
// this error arises when the user is trying to sign in with a different
|
||||
// browser than the one they used to request the sign in link
|
||||
if (isVerifierError(params.error)) {
|
||||
return 'auth:errors.codeVerifierMismatch';
|
||||
return 'auth.errors.codeVerifierMismatch';
|
||||
}
|
||||
|
||||
// fallback to the default error message
|
||||
return `auth:authenticationErrorAlertBody`;
|
||||
return `auth.authenticationErrorAlertBody`;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'server-only';
|
||||
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { createServerClient } from '@supabase/ssr';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'server-only';
|
||||
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
|
||||
import { Database } from '../database.types';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'server-only';
|
||||
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
import { createServerClient } from '@supabase/ssr';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'server-only';
|
||||
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod';
|
||||
|
||||
const message =
|
||||
'Invalid Supabase Secret Key. Please add the environment variable SUPABASE_SECRET_KEY or SUPABASE_SERVICE_ROLE_KEY.';
|
||||
'Invalid Supabase Secret Key. Please add the environment variable SUPABASE_SECRET_KEY.';
|
||||
|
||||
/**
|
||||
* @name getSupabaseSecretKey
|
||||
@@ -13,14 +12,12 @@ const message =
|
||||
export function getSupabaseSecretKey() {
|
||||
return z
|
||||
.string({
|
||||
required_error: message,
|
||||
error: message,
|
||||
})
|
||||
.min(1, {
|
||||
message: message,
|
||||
})
|
||||
.parse(
|
||||
process.env.SUPABASE_SECRET_KEY || process.env.SUPABASE_SERVICE_ROLE_KEY,
|
||||
);
|
||||
.parse(process.env.SUPABASE_SECRET_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod';
|
||||
|
||||
/**
|
||||
* Returns and validates the Supabase client keys from the environment.
|
||||
@@ -7,18 +7,14 @@ export function getSupabaseClientKeys() {
|
||||
return z
|
||||
.object({
|
||||
url: z.string({
|
||||
description: `This is the URL of your hosted Supabase instance. Please provide the variable NEXT_PUBLIC_SUPABASE_URL.`,
|
||||
required_error: `Please provide the variable NEXT_PUBLIC_SUPABASE_URL`,
|
||||
error: `Please provide the variable NEXT_PUBLIC_SUPABASE_URL`,
|
||||
}),
|
||||
publicKey: z.string({
|
||||
description: `This is the public key provided by Supabase. It is a public key used client-side. Please provide the variable NEXT_PUBLIC_SUPABASE_PUBLIC_KEY.`,
|
||||
required_error: `Please provide the variable NEXT_PUBLIC_SUPABASE_PUBLIC_KEY`,
|
||||
error: `Please provide the variable NEXT_PUBLIC_SUPABASE_PUBLIC_KEY`,
|
||||
}),
|
||||
})
|
||||
.parse({
|
||||
url: process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
publicKey:
|
||||
process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_KEY ||
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
|
||||
publicKey: process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_KEY,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export function useSignInWithEmailPassword() {
|
||||
const response = await client.auth.signInWithPassword(credentials);
|
||||
|
||||
if (response.error) {
|
||||
throw response.error.message;
|
||||
throw response.error;
|
||||
}
|
||||
|
||||
const user = response.data?.user;
|
||||
|
||||
@@ -12,7 +12,7 @@ export function useSignInWithProvider() {
|
||||
const response = await client.auth.signInWithOAuth(credentials);
|
||||
|
||||
if (response.error) {
|
||||
throw response.error.message;
|
||||
throw response.error;
|
||||
}
|
||||
|
||||
return response.data;
|
||||
|
||||
@@ -49,7 +49,7 @@ export function useSignUpWithEmailAndPassword() {
|
||||
throw new WeakPasswordError(errorObj.reasons ?? []);
|
||||
}
|
||||
|
||||
throw response.error.message;
|
||||
throw response.error;
|
||||
}
|
||||
|
||||
const user = response.data?.user;
|
||||
|
||||
Reference in New Issue
Block a user