#is it best practice to put a server component as a child of a client component

6 messages · Page 1 of 1 (latest)

plush hinge
#

template.tsx:

"use client";

import { Navbar } from "@/components/navbar";
import { Footer } from "@/components/footer";
import { motion } from "framer-motion";

export default function Template({ children }: { children: React.ReactNode }) {
  return (
    <motion.div
      initial={{ opacity: 0 }}
      animate={{ opacity: 1 }}
      transition={{ ease: "easeInOut", duration: 0.5 }}
    >
      <Navbar />
      {children}
      <Footer />
    </motion.div>
  );
}
wide stoneBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

glass cosmos
# plush hinge template.tsx: ```tsx "use client"; import { Navbar } from "@/components/navbar"...

if the server component is a child like:

<ClientComponent>
  <ServerComponent />
<ClientComponent>

Then the server component would be translated to a client component automatically. If you do it like your example (with children):

<ClientComponent>
  {children}
<ClientComponent>

Then you server component stays a server component and thats a good pratice, if you need that component to be a server component

glass cosmos
#

@plush hinge solved?

plush hinge
#

yes thank you

wide stoneBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer

[Click here](#1267432566386982985 message)