Next.js Discord

Discord Forum

doesnt compile

Answered
Erythrina gall wasp posted this in #help-forum
Open in Discord
Avatar
Erythrina gall waspOP
 ✓ Starting...
 ✓ Ready in 4.3s
its stuck here
Answered by Diamond Master
it is supposed to be there
View full answer

40 Replies

Avatar
it is supposed to be there
Answer
Avatar
wdym it doesn't compile
Avatar
Erythrina gall waspOP
No its stuck there
Isnt it supposed to show
/compiling ?
Avatar
this?
Image
Avatar
Erythrina gall waspOP
Yes
This doesnt come
Avatar
only if you access the page
Avatar
Erythrina gall waspOP
Ohh
My bad
😔
Ima try rhat
Wait
"use client";


import { ClerkProvider, useAuth } from "@clerk/nextjs";
import { AuthLoading, Authenticated, ConvexReactClient, Unauthenticated } from "convex/react";
import { ConvexProviderWithClerk } from "convex/react-clerk";

interface ConvexClientProviderProps {
    children: React.ReactNode;
};

const convexUrl = process.env.NEXT_PUBLIC_CONVEX_URL!;

const convex = new ConvexReactClient(convexUrl);

export const ConvexClientProvider = ({
    children
}: ConvexClientProviderProps) => {
    return (
        <ClerkProvider afterSignUpUrl="/sign-up">
            <ConvexProviderWithClerk useAuth={useAuth} client={convex}>
                {/* <AuthLoading>
                    <Loading />
                </AuthLoading> */}
                <Authenticated>
                    {children}
                </Authenticated>
                <Unauthenticated>
                    {children}
                </Unauthenticated>
            </ConvexProviderWithClerk>
        </ClerkProvider>
    )
}
i have a convex provider
but
it doesnt direct me to the sign up page
why is that?
Avatar
i don't think env vars can be accessed by client
Avatar
@Diamond Master i don't think env vars can be accessed by client
Avatar
Erythrina gall waspOP
ooooo
okay
Avatar
try to manually put the string for now
and check
Avatar
@Diamond Master try to manually put the string for now
Avatar
Erythrina gall waspOP
still doesnt work
:(
Avatar
i never used Convex, srry
try to check the console
Avatar
Erythrina gall waspOP
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ConvexClientProvider } from "@/providers/convex-client-provider";

const geistSans = Geist({
  variable: "--font-geist-sans",
  subsets: ["latin"],
});

const geistMono = Geist_Mono({
  variable: "--font-geist-mono",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body
        className={`${geistSans.variable} ${geistMono.variable} antialiased`}
      >
        <ConvexClientProvider>
          
        {children}
        </ConvexClientProvider>
      </body>
    </html>
  );
}
Avatar
or remove that "use client"
Avatar
Erythrina gall waspOP
is it due to the layout?
Avatar
@Diamond Master or remove that "use client"
Avatar
Erythrina gall waspOP
it shows an error when i do that
Avatar
which one
Avatar
Erythrina gall waspOP
Server Error

TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
Avatar
ah
idk then, srry
Avatar
Erythrina gall waspOP
its okay
dont worry :)
Avatar
Asian black bear
Please don't use a single thread for chaining multiple issues. Second, you should read up on the Convex docs how to set it up and in case you have issues open another thread with a descriptive title and sufficient details for others to help you.