What exactly does `unstable_noStore` do?
I'm developing on the t3 stack with clerk as the auth. When I try to call one of my protected endpoints, I get the following error when building
I don't really understand why this error occurs when only the
auth
method is being used from Clerk in the trpc context, but using unstable_nostore
in the components that do call the endpoints, fixes this issue.
Does anyone know what exactly is going on here?1 Reply
By default Nextjs wants to cache all responses, but if the endpoint requires auth it can't cache it (or it might expose cached the data to a wrong/not authed user). If you put
noStore()
it tells Next to never cache this endpoint or server component.