Skip to content

Commit

Permalink
feat: add i18n support for Dashboard url used in Clerk
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Dec 3, 2023
1 parent 5e1af6c commit 12b89bc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .env
Expand Up @@ -11,9 +11,6 @@ DATABASE_URL=file:next-js-boilerplate.db
# Clerk authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_bGlnaHQtbGFicmFkb3ItNTEuY2xlcmsuYWNjb3VudHMuZGV2JA

NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard

######## [BEGIN] SENSITIVE DATA ######## For security reason, don't update the following variables (secret key) directly in this file.
######## Please create a new file named `.env.local`, all environment files ending with `.local` won't be tracked by Git.
######## After creating the file, you can add the following variables.
Expand Down
4 changes: 4 additions & 0 deletions src/app/[locale]/(auth)/layout.tsx
Expand Up @@ -11,6 +11,7 @@ export default function AuthLayout({
let clerkLocale = enUS;
let signInUrl = '/sign-in';
let signUpUrl = '/sign-up';
let dashboardUrl = '/dashboard';

if (locale === 'fr') {
clerkLocale = frFR;
Expand All @@ -19,13 +20,16 @@ export default function AuthLayout({
if (locale !== 'en') {
signInUrl = `/${locale}${signInUrl}`;
signUpUrl = `/${locale}${signUpUrl}`;
dashboardUrl = `/${locale}${dashboardUrl}`;
}

return (
<ClerkProvider
localization={clerkLocale}
signInUrl={signInUrl}
signUpUrl={signUpUrl}
afterSignInUrl={dashboardUrl}
afterSignUpUrl={dashboardUrl}
>
{children}
</ClerkProvider>
Expand Down
6 changes: 0 additions & 6 deletions src/libs/Env.mjs
Expand Up @@ -11,8 +11,6 @@ export const Env = createEnv({
},
client: {
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().nonempty(),
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL: z.string().nonempty(),
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL: z.string().nonempty(),
},
// You need to destructure all the keys manually
runtimeEnv: {
Expand All @@ -21,9 +19,5 @@ export const Env = createEnv({
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:
process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL:
process.env.NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL,
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL:
process.env.NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL,
},
});

0 comments on commit 12b89bc

Please sign in to comment.