vercel / vercel/next.js

Docs: How to "use cache" but only at runtime (not build)

Open Beginner friendly
#86,686 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Cache Components
Dominant language
JavaScript
Stars
142k
Forks
32.5k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

What is the documentation issue?

I want to "use cache" some DB queries (in memory), but I absolutely don't want them to be pre-rendered during the build (my build environment doesn't even have access to the database). How do I exclude those from prerendering?

I initially thought I could await connection() but it doesn't work inside "use cache".

Is there any context that might help us understand?
Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/getting-started/cache-components

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cache components documentation at https://nextjs.org/docs/app/getting-started/cache-components and review its guidance on cached database queries and prerendering. Update the page to explain how to keep "use cache" queries from running during the build, including the relevant runtime-only pattern; the issue is done when this scenario is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.