mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat: add clerk auth support with convex (#548)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "../index.css";
|
||||
import Providers from "@/components/providers";
|
||||
{{#if (eq auth "clerk")}}{{#if (eq backend "convex")}}import { ClerkProvider } from "@clerk/nextjs";
|
||||
{{/if}}{{/if}}import Providers from "@/components/providers";
|
||||
import Header from "@/components/header";
|
||||
|
||||
const geistSans = Geist({
|
||||
@@ -24,18 +25,25 @@ export default function RootLayout({
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
<Providers>
|
||||
<div className="grid grid-rows-[auto_1fr] h-svh">
|
||||
<Header />
|
||||
{children}
|
||||
</div>
|
||||
</Providers>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
{{#if (and (eq auth "clerk") (eq backend "convex"))}}<ClerkProvider>
|
||||
<Providers>
|
||||
<div className="grid grid-rows-[auto_1fr] h-svh">
|
||||
<Header />
|
||||
{children}
|
||||
</div>
|
||||
</Providers>
|
||||
</ClerkProvider>{{else}}<Providers>
|
||||
<div className="grid grid-rows-[auto_1fr] h-svh">
|
||||
<Header />
|
||||
{children}
|
||||
</div>
|
||||
</Providers>{{/if}}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
"use client";
|
||||
|
||||
{{#if (eq backend "convex")}}
|
||||
{{#if (eq auth "clerk")}}
|
||||
import { useAuth } from "@clerk/nextjs";
|
||||
import { ConvexReactClient } from "convex/react";
|
||||
import { ConvexProviderWithClerk } from "convex/react-clerk";
|
||||
{{else}}
|
||||
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#unless (eq api "none")}}
|
||||
import { QueryClientProvider } from "@tanstack/react-query";
|
||||
@@ -34,7 +40,13 @@ export default function Providers({
|
||||
disableTransitionOnChange
|
||||
>
|
||||
{{#if (eq backend "convex")}}
|
||||
{{#if (eq auth "clerk")}}
|
||||
<ConvexProviderWithClerk client={convex} useAuth={useAuth}>
|
||||
{children}
|
||||
</ConvexProviderWithClerk>
|
||||
{{else}}
|
||||
<ConvexProvider client={convex}>{children}</ConvexProvider>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#unless (eq api "none")}}
|
||||
<QueryClientProvider client={queryClient}>
|
||||
|
||||
Reference in New Issue
Block a user