Skip to content
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

docs: Next.js 14 #57342

Merged
merged 21 commits into from
Oct 26, 2023
Merged

docs: Next.js 14 #57342

merged 21 commits into from
Oct 26, 2023

Conversation

leerob
Copy link
Member

@leerob leerob commented Oct 24, 2023

  • Fetch logging configuration is no longer experimental
  • Add unstable_noStore reference
  • Add unstable_cache reference
  • Add codemod docs for next/og import changes
  • Update docs around stable Server Actions
  • Add example of revalidating the entire data cache
  • Update static export docs for next export command removal
  • Update minimum required Node.js version
  • Add viewport and generateViewport reference

@leerob leerob requested review from timeyoutakeit and delbaoliveira and removed request for a team October 24, 2023 16:37
@leerob
Copy link
Member Author

leerob commented Oct 24, 2023

Still need to add a reference for #57287, will do that shortly.

docs/01-getting-started/01-installation.mdx Outdated Show resolved Hide resolved
Copy link
Collaborator

@molebox molebox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left committable suggestions for ease. Some are questions so feel free to resolve if not adding them 👍🏻

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 3 questions raised when I'm reading this. It would be super helpful if the doc also addressed those.

  1. Does unstable_cache also handle deduplication, which is not the case for the current version of this API?
  2. Is it supposed to be used OUTSIDE of a component, instead of inside as suggested in the previous version of the doc?
  3. If the answer to (3) is yes, then how should one specify tags that depend on the function arguments? e.g.
const getCachedUser = unstable_cache(
  async (id) => getUser(id),
  ['user'],
  { tags: [`user-${id}`] }  // ???
);

Copy link

@alfonsusac alfonsusac Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both current and previous docs, unstable_cache can be used both inside and outside of the component. However, when calling the function returned from unstable_cache it has to be inside.
Based on my current understanding, this is because the object that is used to access the cache IncrementalCache only exists inside a serverless function such as Server Components and generateMetadata() which is why it will throw an error if called outside of the component.

I assume the example below is used so that one can export the function and use it somewhere else. This is, through my experience, done by wrapping unstable_cache with a function that receives any external data which can be passed to the keyParts and inside the callback function.

Example:

const getCachedUser = (slug) => unstable_cache(
  async (slug) => getUser(slug),
  ['my-app-user'],
  { tags: [`user-${slug}`] }
)(slug);

export default async function Component({ userID }) {
  const user = await getCachedUser(userID);
  ...
}

This has worked for me, last time i checked in 13.4.9

@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2023

All broken links are now fixed, thank you!

kodiakhq bot and others added 2 commits October 25, 2023 18:14
…etching-caching-and-revalidating.mdx

Co-authored-by: Amy Burns <amy.burns@vercel.com>
Co-authored-by: Michael Novotny <manovotny@gmail.com>
delbaoliveira
delbaoliveira previously approved these changes Oct 26, 2023
@kodiakhq kodiakhq bot merged commit 92b4d67 into canary Oct 26, 2023
58 checks passed
@kodiakhq kodiakhq bot deleted the doczzz branch October 26, 2023 15:30
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants