-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
[Feat]: SSR support #202
Comments
Hi @bartlomiejzuber, Thank you for your bug report. It might come as a surprise but this is expected. At the time of writing, Embla Carousel is a client side script and won't do anything on the server. This is what's happening:
One way to solve this would be to hide the carousel with SSR support might be added in the future. Best, |
@davidjerleke Do you think the approach suggested in this issue, helps fix this problem? FormidableLabs/nuka-carousel#786 (comment) ? |
Hi @manojVivek, Thanks for sharing that. Currently, the HTML gets server side rendered and you don't loose any important SEO. I think the flicker thing is solvable with a similar approach as you suggest, but if this is going to be implemented we need to ask ourselves at what cost? How much will it affect bundle size and what would be a good solution for this? |
@davidjerleke Thanks for mentioning this issue! But could you help me with something? How could I control if the embla has initialized or not? |
@davidjerleke Thanks! I fixed my problem with the solution bellow and while the embla isn't rendered I show a Skeleton
|
Hi all, in case it's of any help to anyone, here's my approach to a related problem (SSR). I have a page with a big carousel (product images) of which the currently selected is stored in a query param of the URL. To achieve a server-rendered HTML that is already pointing to the correct image i added a translation to the Reduced example (from my components based on shadcn's): <div ref={carouselRef} className="overflow-hidden">
<div
ref={ref}
className="flex"
style={{ transform: `translateX(-${initialIdx * 100}%)` }}
/>
</div> This translation is overridden by Embla with a Hope it helps anyone! |
This feature has been added to the roadmap: |
Hi @davidjerleke. |
Hi @sarussss, Thank you for your question. The SSR feature will be released with v9 and it will be an opt-in feature. By default, it won’t be active. So if that’s your concern, you will be able to use Embla just as you do today without any problems. But the bundle size will grow a little bit because SSR is the kind of feature that has to be built into the core. However, the bundle size won’t grow significantly. Maybe I will consider lifting out an existing feature and make it a plugin so the bundle size won’t grow but I haven’t decided that yet. Did that answer your question? |
Hi @davidjerleke |
Hey @sarussss, Sorry if I wasn’t clear 🙂. The SSR feature needs to be integrated into the core because it impacts several parts of the core code, so it can't be a plugin. What I meant was that I might consider removing a different feature and turning that into a plugin instead, in order to reduce the core library's bundle size. |
Hi @davidjerleke, |
@sarussss no, SSR can’t be a plugin. It has to be added to the core library, meaning the |
Note
Edit: This feature is under development:
Edited by @davidjerleke 2024-12-26.
Bug is related to
Embla Carousel version
Describe the bug
CodeSandbox
Steps to reproduce
Expected behavior
Additional context
The text was updated successfully, but these errors were encountered: