SolidJSS
SolidJSβ€’17mo agoβ€’
17 replies
Angelelz

Solid way to Show components based on information from the session or cookies or server only data?

With RSC, our team is used to use data available only in the server in the context of a request, like from headers, cookies, or even server only string arrays. For example:
const updates300 = ["user1", "user2", "user3"];

export default async function Home() {
  const user = await getUserOrRedirect();

  return (
    <div className="flex flex-col items-center justify-center p-4">
      <H1 className="text-center">Welcome {user.fullName}</H1>
    {updates300.includes(user.userId) && <Update300 />}
    ...
    </div>
  )
}

Is there a "solid way" to do this in solid start? Or we should just use
createResource
and a server actions? I'm hoping there is a way to run code only on the server without it being a server action.
Was this page helpful?