-
Notifications
You must be signed in to change notification settings - Fork 36
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
Sometimes I'm receiving: You can't use getStoryblokApi if you're not loading apiPlugin error #952
Comments
I encountered a similar issue and resolved it by directly fetching the API instead of using the getStoryblokApi function. |
@alisayed95 and how do you handle Cache Invalidation ? |
@nmsdvid by adding query parameter cv. |
Same issue here, I've the issue even with the Storyblok boilerplate (https://github.com/storyblok/next.js-13-boilerplate). That's happen when I'm in editor, and save the story, the visual editor reset all data to public data. |
I am also using Next.js with a Vercel deployment and seeing this error come up. |
Same issue here. Only happens when I use |
I'm experiencing the same issue. I noticed it when I upgraded to the latest version of Next.js, so I went through the versions and found that v14.0.3 is the last version everything works OK. From v14.0.4 onwards, it breaks as described above. I then went through the canary versions, and believe the issue was introduced in Next.js v14.0.4-canary.7. So, potentially, this is a Next.js issue rather than a |
A workaround (for now) is to build your own implementation. I completely replaced the
I can now directly import getStoryblokApi in my individual app router pages from this implementation, and my error has been gone since. |
We have this issue too. We are implementing Storyblok and as @stevegreenn wrote, the problem does not appear in 14.0.3 but is still a problem in 14.1.0. Since the message is so Storyblok specific, where does one start to formulate a bugreport in vercel/next.js/issues? |
+1 same problem. When using the custom |
+1 would be awesome to see this getting fixed :D |
Even on 14.0.3 I had the issue, downgrading to latest 13 fixed the problem for me altough on other projects I don't have the problem on 14.0.3 ... |
same problem. |
Is there any update regarding this issue? |
Over here just having the same issue. Hoping there will be a fix soon? Also, why |
Hey everyone! Meanwhile, it would be great if any of you could share anything that we can reproduce - we are trying to look at a couple of examples, and it would be great to see some more. Thank you so much! :) cc - @fgiuliani @alexjoverm |
March 28 and we still have this problem 😩 |
facing same issue, once you reload page it works fine. |
This works for certain use cases but it's not 100% failproof. |
Sorry if this is not relevant for everyone, but I had this issue and realised that it helped to import "storyblokInit" and "apiPlugin" and then initiate Storyblok with the token in each component/route I fetch data from the API. So basically add:
to every component where you want to fetch data. |
Hey everyone! We tried implementing a few things, and we weren't able to replicate the issue properly. What I have for now is the following repo - https://github.com/alexjoverm/reactsdk-952 that Alex created. But - it would be great and helpful if you could use this repo and make some changes to share with us when and where exactly you're facing the issues. Maybe you can extend the project to add something that is causing this issue and share the link for that OR feel free to create pull requests in the same so that we understand the exact issue and can replicate it to make some changes. We highly appreciate your contribution, thank you so much! TL;DR; |
Hey everyone! To give you all an update - as of now, we can see that the Next Link component causes this issue for the first time and it works later after clicking once. I would like to confirm if any of you are facing the error in any different scenario as well. It would be good to know if there are more places other than where this issue occurs. To add on, as mentioned and discussed earlier - it looks like an issue on the Next.js side or the way it Next Link works in the new update. Maybe we are missing something there. We will need to investigate more before arriving at a solution here as we are not completely sure of the reason behind it. There is a temporary fix though - as stated by @saiminh, you can initialize Storyblok in each of the routes. There shouldn't be any performance-related issues in this case (hopefully). Also, here is a link to @alexjoverm 's comment along with a commit to show the quick fix I just mentioned about initializing Storyblok in every route. Please take a look at it as well for a better reference. We will get back to you as soon as we find something, and please share us your findings as well if you find something new. |
Thanks everyone for your patience and working together on this! 👏 |
Is there any update on this? We get the same error when client side navigation is happening (i.e. clicking on a next/link) |
Same problem here |
Same issue here. Following the tutorial found at https://www.storyblok.com/tp/add-a-headless-cms-to-next-js-13-in-5-minutes and it doesn't work. I specifically did the setup where you have the storyblokInit in a provider as well as in the layout file |
Hey all! We're actively investigating this, but unfortunately we haven't found an ideal and clean solution yet. For now, the workaround suggested here by @stmoerman should make the job. |
We’ve created an issue in the Next.js repository for further investigation: Next.js Issue #68882 |
Hi all, we are working on a stable solution to this issue, in PR #1201 is our proposal. We will test this a bit more and you can help us by reviewing and testing it in your projects. Please let us know if you have any feedback, thanks! |
Great! I would love to help by testing it in my projects. Is there an easy way to install it in my projects? I thought I could install it with pnpm add github:storyblok/storyblok-react#feat/next-rsc-support But since it's a monorepo, no dice |
@edodusi Perhaps a beta package to install for the people in this thread so everybody can quickly test if it has the expected result? |
hi @dariusrosendahl, sorry for the late response I was on vacation 😄 |
Hi all, we think the new implementation of RSC is ready for a battle test, and we would really appreciate any feedback. In order to integrate it, please follow the steps provided in the update README starting from Thank you for your contribution! |
@edodusi any chance to see this PR merged into main? |
@andrea-budel-remedia yes, definitely. We are looking for some more feedback to ensure we don't break existing implementations, but we plan to merge and release this soon. If you can help, I encourage you to try the latest dev build, you can find it somewhere in the comments here! |
Hi everyone, we just released v4.0.0 with improved support for Server Components. There are some changes to the implementation, please find them on the updated README. I will now close this issue, and I encourage you to try the new release and report any trouble opening a new one. Thank you all for your support |
@edodusi am I right in thinking that now you can have full server components while still maintaining editing capabilities with visual editor? Before you had to choose a path. Either:
|
@richardtaylordawson you are right |
@edodusi that's amazing!!! I'm implementing now! super excited for the change! Well done! Quick question. Let's say production is hosted at production.com. Our preview url for editors in storyblok is then production.com How would we turn off the bridge for production.com except when its loaded within storyblok itself? |
@richardtaylordawson this would be a topic for another discussion but I think you shouldn't worry about that because, even if you try to load it, the business logic of the bridge won't actually do anything outside the visual editor. But of course this is something worth discussing, I'll raise the topic internally. |
Describe the issue you're facing
I'm using @storyblok/react/rsc in a Next.js app router setup and sometimes I'm getting an You can't use getStoryblokApi if you're not loading apiPlugin error. After a couple of page refresh the page works again. I already tried to do something like this:
to prevent the issue from happening but with no luck. Actually the code used on the page is pretty straightforward.
Any ideas?
Reproduction
https://www.ai-writer-zerobranded.com/signin
Steps to reproduce
Go to https://www.ai-writer-zerobranded.com click around in the navigation
System Info
Used Package Manager
npm
Error logs (Optional)
You can't use getStoryblokApi if you're not loading apiPlugin.
Validations
The text was updated successfully, but these errors were encountered: