Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
17 replies
Machina0

Noob question: How to pass a string to a child component?

I used prisma to get two strings from a database, now I want to give those two strings to a client component. This is because client components cant use prisma.
I'm new to react, how can I pass these strings to the client component?

I'm thinking something like this:
"use client";

import { NextRequest, NextResponse } from "next/server";
import { redirect } from "next/navigation";
import { signIn } from "next-auth/react";

interface TwoStringsComponentProps {
    email: string;
    token: string;
}

export default function Activate({email, token}:{props: TwoStringsComponentProps}) {

  async function signInCall(){
    const signInResponse = await signIn("credentials", {
      email: {email},
      token: {token},
      callbackUrl: "/dashboard",
    });
  
  }

  signInCall()

    return <div>Hello world</div>;
    //now the cookie should be on the client machine
}


and then the main page.tsx would have like:

<Activate email={email} token={token} />


How should I do this? This has been taking an embarrassing amount of time trying to figure out.
Was this page helpful?