-
-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use flowbite-react in React Server Components #448
Comments
@focux could you please update your |
Updated to the latest version (0.3.5) and still happening. |
We are discussing this on Discord: https://discordapp.com/channels/902911619032576090/1047993578401562624 |
I want to resume the discussion so far: Every single component of Source: https://beta.nextjs.org/docs/rendering/server-and-client-components |
@rluders That makes sense. Will there eventually be a way to work around this? I would like to take advantage of server components while using flowbite |
Well, it is hard to say. I know that ppl for other libraries, like material-ui, also are having the same issue. I'm not that much into react/nextjs universe, so... by now, the best thing is to pay attention to other libs moves and wait 'till someone interested in work on this one shows up. |
I'm seeing the same on flowbite-react 0.3.7. Ideally all flowbite-react component parts that require interactivity/state/hooks would be moved to leaves of the render tree, so that server component rendering could be taken advantage of. For now I'm using the workaround shown in the Next.js 13 docs, which makes a root flowbite-react component (e.g.,
'use client';
import { Avatar } from 'flowbite-react';
export default Avatar; Original issue for reference:
|
May I also add my 2 cents - the general consensus in the React / Next.js / Remix ecosystem is that the path forward are server rendered components, meaning we should really take into account providing official support or at least documenting a workaround as people using Flowbite React and choosing to use SSC are going to have trouble using the library from the get-go. |
Let's pivot this issue to focus on writing documentation on how to implement flowbite-react in React Server Components. I already have on the flowbite-next-starter, so I know it works correctly, you just need to recognize that these components in many cases depend on client-side state to function, which we can easily document. |
@tulup-conner but currently all components will break (like even eg buttons) during SSR. What is to document, like adding |
You can't conditionally call a hook, so I'm not sure how we could make the theme optional, ergo, allow components to be fully server side rendered without JS. People need to be able to systematically customize the design system, and the cost of that is JS in the client, or at least seems to be. I may just be unaware of another option. My Remix and Vite projects work out of the box with this library with JS enabled. The problem only arises when you try to load the page without JS, and there are no classes applied. Obviously, that sucks too. I don't really know what the step forward is. |
I just recently discovered Flowbite and Flowbite React and it being a Tailwind based library, I assumed to change the theme, I could just change the Tailwind config. If that was a possibility, there would not be any need for JS to change the theme. Especially since Flowbite React already requires the use of the |
We have discussed it before for sure but that's quite alright! It's another option on the menu for sure, and something I wanted when I first started using the library as well. I haven't toyed with it with actual code but in theory there's no reason we can't. I've read the config file in personal projects >2 years ago and it worked well enough. I imagine it only works better now. In an ideal world, I'd like to add an optional build step that takes your tailwind config and generates flowbite-react components without |
This issue has me steering away from flowbite unfortunately. |
From my experience of using Flowbite React adding Interactive components are NOT supposed to be server components, as per the Next.js documentation. I believe it's up to the developer to properly separate client and server components based on interactivity. That being said, together with @tulup-conner we're planning on improving the examples based on the new docs redesign PR that we're working on quite a lot these past few weeks #642. This PR should provide a much better SSC support for the currently existing examples. Cheers, |
literally just purchased flowbite for use in a next.js app, but this is proving to be problematic. Probably going to have to roll most of the functionality myself and just use flowbite html blocks which somewhat defeats the point. |
@marcodenic do you know that flowbite-react is free, right? |
yeah but I've been using the stuff for ages and we wanted access to the full figma file too. but just discovered it's all a bit problematic during implementation. |
@marcodenic well, right now most react libraries are having issues with SSC. I'm working in some idea to provide some support for it, but during my free time, that isn't much. The project is open source, so... feel free to contribute and fix the problematic parts, it will be most than welcome. |
it wasn't a slight, I paid because I love flowbite and wanted to use it and support it. I'll still use it, I only need a few interactive components so I'll just roll my own for now until ssc stuff is done, just need to do a bit more code than anticipated. |
my solution to work on this is to create a file with in this example i use nextjs {root}/src/flowbite-components.tsx (you could name the file whatever you want) "use client";
export * from "flowbite-react"; {root}/src/app/page.tsx import { Alert } from "@/flowbite-components"
export default function Home() {
return <>
<Alert color="info">
<span>
<span className="font-medium">
Info alert!
</span>
{' '}Change a few things up and try submitting again.
</span>
</Alert>
</>
} |
@BanDroid That's actually not the worst solution... Nice. Regardless, we are well aware of this issue and have plans to resolve the core problem, which is that every component needlessly uses the client to support |
|
@ozelen Please see the comment above - components needlessly use the client, which will be changed so you can render React Server Components with Flowbite React. |
In order to get around the
|
Is the "use client" everywhere the only supported way? This kind of defeats the point of server components |
Yep. We are aware of that, it's just a workaround. Good news: this is the next thing on my docket and I expect to have something resembling a solution in August. |
For something like
Which is self explanatory. Any workarounds for this? |
Hey all, I just opened up a discussion at #923 with a few possible solutions to this problem. I want to personally thank @BanDroid and @nickjanssen again for providing their solutions that already work! Please check that discussion out and give a vote and/or comment on your favorite solution(s). And please let us know there, too, if you have any ideas we didn't present. |
Flowbite-react only support client components at the moment. Even if, for now, we only use such component in CountriesView, there is no interest in using a component library only for a small porty of the project (espectially the one where its cost is the highest). see themesberg/flowbite-react#448
Flowbite-react only support client components at the moment. Even if, for now, we only use such component in CountriesView, there is no interest in using a component library only for a small porty of the project (espectially the one where its cost is the highest). see themesberg/flowbite-react#448
Folks, Please test the 0.7.0-beta.2 release. It introduces some RSC support and improves the theme by converting it from Context to Singleton. It shouldn't introduce any breaking change. If you find any issues, please, report them as an issue, and don't forget to say that you are using the beta version. |
Update: small patch for the imports failing 0.7.0-beta.3 |
Update: 0.7.0-beta.4 is out, bringing even more RSC support for the following components:
|
Some feedback on this beta (LMK if this issue isn't the best place for this feedback). Here's the version in my When I import the sidebar components from
|
Should be fixed in 0.7.0-beta.5. |
Update: 0.7.0-beta.5 brings full RSC support for all |
hi, just want to notice. please dont rely on sharp as dependency, it is not working in termux for android users. i cant use flowbite 0.7.0-beta.5 because sharp also rely on libvips natively, what kind of css library relying on native libraries? |
Describe the bug
There are some static components that should work on server components (Next.js 13), for instance, the avatar component—and many others—but for some reason is throwing the error below that seems to be coming from
floating-ui
:To Reproduce
Steps to reproduce the behavior:
Expected behavior
Static components should work on server components
System information:
Project information:
The text was updated successfully, but these errors were encountered: