Fetch Fresh data from Builder using sdk after Builder content is updated

Hi,
I am currently using the fetchOneEntry function from the @builder.io/sdk-react-nextjs package to retrieve data from a specific model in Builder content. However, I am encountering a couple of issues when updating the content.

  1. When I update the content in Builder, the function does not return the updated data until after three function calls. Despite using all available options to disable the cache, the problem persists.

const builderResponse: any = await fetchOneEntry({
model: “model-name”,
apiKey: BUILDER_KEY,
staleCacheSeconds: 0,
cacheSeconds: 0, limit: 1,
sort: { createdDate: -1 },
});
Note: The cachebust option was not available in this function.

This behavior is causing issues with displaying the latest data on my home page, as I am using Next.js static site generation. I revalidate the page whenever there is an update in the Builder content to rebuild the page and show the latest data. However, due to Builder’s caching behavior, I receive the cached data instead of the updated data on the first build.
Is there a way to ensure that fresh data is available on the first call itself immediately after the content is updated in Builder instead of the old cached data.

I have also tried using the builder.get() method from the @builder.io/sdk package to fetch the latest data after content is updated,
const builderResponse = await builder.get(“model-name”, {
limit: 1,
sort: { createdDate: -1 },
cachebust: true,
cacheSeconds: 0,
});
However, I encountered the same issue where the updated data is only received on the second call.

  1. I also wanted to understand the stability and support for @builder.io/sdk-react-nextjs since its currently in beta

Thank you.

NextJS, react

Hello Nehal,

Would you be able to share the implementation code? I may be able to provide better guidance if I can see how the function is being used in your pages.tsx file or equivalent.

Do you have a good solution for a similar problem I encountered?