Commit graph

34 commits

Author SHA1 Message Date
Lee Robinson
92b4d6737c
docs: Next.js 14 (#57342)
- 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

Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2023-10-26 15:30:43 +00:00
Josh Story
5528cc6d4e
Remove the experimental serverActions flag (#57145)
Remove the experimental `serverActions` flag

Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-10-20 20:45:25 +00:00
Josh Story
0a80017d03
Update React from d900fadbf to 09fbee89d. Removes server context and experimental prefix for server action APIs (#56809)
The latest React canary builds have a few changes that need to be
adopted for compatability.

1. the `useFormState` and `useFormStatus` hooks in `react-dom` and the
`formData` opiont in `react-dom/server` are no longer prefixed with
`experimental_`
2. server content (an undocumented React feature) has been removed. Next
only had trivial intenral use of this API and did not expose a coherent
feature to Next users (no ability to seed context on refetches). It is
still possible that some users used the React server context APIs which
is why this should go into Next 14.

### React upstream changes

- https://github.com/facebook/react/pull/27513
- https://github.com/facebook/react/pull/27514
- https://github.com/facebook/react/pull/27511
- https://github.com/facebook/react/pull/27508
- https://github.com/facebook/react/pull/27502
- https://github.com/facebook/react/pull/27474
- https://github.com/facebook/react/pull/26789
- https://github.com/facebook/react/pull/27500
- https://github.com/facebook/react/pull/27488
- https://github.com/facebook/react/pull/27458
- https://github.com/facebook/react/pull/27471
- https://github.com/facebook/react/pull/27470
- https://github.com/facebook/react/pull/27464
- https://github.com/facebook/react/pull/27456
- https://github.com/facebook/react/pull/27462
- https://github.com/facebook/react/pull/27461
- https://github.com/facebook/react/pull/27460
- https://github.com/facebook/react/pull/27459
- https://github.com/facebook/react/pull/27454
- https://github.com/facebook/react/pull/27457
- https://github.com/facebook/react/pull/27453
- https://github.com/facebook/react/pull/27401
- https://github.com/facebook/react/pull/27443
- https://github.com/facebook/react/pull/27445
- https://github.com/facebook/react/pull/27364
- https://github.com/facebook/react/pull/27440
- https://github.com/facebook/react/pull/27436

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-10-16 15:46:10 -07:00
Michael Novotny
fd2724ace0
Changes codeblock filename delimiter (#56712)
Based on feedback from #56603, the `/` can be interpreted as file paths instead of filename separators / delimiters. We'll change them to use pipes `|` instead.
2023-10-12 23:18:22 +00:00
Zeeshan Ali
bfc2ab9cff
corrected sentence (#56595)
Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-10-09 02:08:50 +00:00
Radu Petre Tarean
06ee9d7ca0
docs: update code snippet for correct file name (#56006)
params would be undefined on the /item route, i believe the route should be /item/[id]
2023-10-07 00:41:03 +00:00
Vũ Văn Dũng
7f6a494e9e
docs: Use Response.json over NextResponse.json (#56173)
TypeScript 5.2 now supports `Response.json` (https://github.com/microsoft/TypeScript/issues/52841). That means, if we just need to return a JSON `Response`, we no longer need to import `NextResponse`. This PR updates all such instances in the documentation to use `Response.json`.
2023-09-28 19:36:21 +00:00
Bozhen
9cd46e335c
docs: Renamed function that is used by other name (#56170)
In "app/actions.ts" the function is named like create(), but in "app/add-form.tsx" file "createTodo" function is imported and used. This is related to TypeScript examples, .js files are ok.

### What?

Renamed a function.

### Why?

There are two example files in docs ([Error Handling](https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#error-handling) section) and the `app/add-form.tsx` is importing function `create` from `app/actions.ts` by another name (`createTodo`).

### How?

Fixed by renaming function to `createTodo`, to match .js file with the same example.
2023-09-28 15:05:24 +00:00
Lee Robinson
c7ff12b753
docs: update next-forms example (#55927)
A few bits of follow up from my previous PR updating the forms example.
2023-09-25 21:41:14 -05:00
Mostafa Gouda
8f7d83f1fd
docs: Add note that Server Actions work with static routes (#55626)
In the new next.js v13.5 blog post, the [other improvements section](https://nextjs.org/blog/next-13-5#other-improvements) mentions:

> [Improvement] Server Actions now work with fully static routes (including revalidating data with ISR)

In the forms and mutation docs page, the [good to know section](https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#how-server-actions-work) mentions:

> Currently, if a route uses a Server Action, it is required to [render dynamically](https://nextjs.org/docs/app/building-your-application/rendering/server-components#server-rendering-strategies).

I have changed the good to know section to convey the new improvement mentioned in the v13.5 blog post
2023-09-24 15:03:16 +00:00
Lee Robinson
5f4238d9fa
docs: useFormState (#55564)
This PR shows how to use a new React hook `useFormState` in the context
of the [Forms and
Mutations](https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations)
docs. It also updates the forms example (`next-forms`) to show the
recommended patterns for loading / error states.

Related: https://github.com/vercel/next.js/pull/55399
---
Co-authored-by: John Pham <johnphammail@gmail.com>
2023-09-22 16:10:25 -05:00
S3Prototype
69a8878631
Feedback: Remove line saying server actions is dynamic-only (#55746)
- Removes a line from next docs that is no longer accurate:
> Currently, if a route uses a Server Action, it is required to render
dynamically.
According

With the release of Next.js 13.5, Server Actions now work with fully
static routes (including revalidating data with ISR).


<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-09-21 10:43:42 -05:00
Alexandre Ferreira
cd1a50f133
Update 03-forms-and-mutations.mdx (#55386)
A unique key is required for each item on a list.
2023-09-14 17:17:13 +00:00
Michael Novotny
fe797c1074
Updates Mozilla links to not include language preference (#55326)
Internal suggestion to remove `en-US` from Mozilla urls since MDN is
available in multiple languages nowadays it will automatically redirect
to the viewer’s language preference.

Closes
[DX-2076](https://linear.app/vercel/issue/DX-2076/make-external-mozilla-links-language-agnostic-in-nextjs-docs)
2023-09-13 11:06:29 -05:00
Michael Angelo Rivera
d02124aae6
docs: clarify data type in Forms and Mutations section (#54630)
### What?

Clarify the "Forms and Mutations" docs. 

### Why?

This may be opinionated, but I believe this section of the docs starts out assuming that the user knows how the `<form>` HTML works. Coming from the client side React world, most developers are used to using state in forms. Clarifying that this data is accessible via the standard web API [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData) is essential for both transitioning developers and new developers.
2023-08-30 13:20:55 +00:00
vinay
8374e24a39
(Docs) Add missing JS-Code, cookies function names updated accordingly. (#54703)
Changed the name of the actions to `delete` and `read` to indicate the appropriate operation.
2023-08-30 12:03:17 +00:00
Lee Robinson
68331892cc
docs: Add JS code snippets for forms (#54577)
https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations

Some of the code blocks where I only specified TS code snippets aren't
working with JS as well (when there are no types). I think I might have
incorrectly assumed you could leave those out. So added the JS snippets
in here (same code, just different file names).
2023-08-27 11:37:10 -05:00
Delba de Oliveira
05dbd9a8a2
Docs: Update Edge runtime and data revalidation information (#54499)
Fixes: https://vercel.slack.com/archives/C042LHPJ1NX/p1692666204185669

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-08-26 18:33:15 -07:00
Lee Robinson
b048d7eee2
docs: Forms and mutations (#54314)
This PR is a larger change to documentation to make the following
updates:

- Deconstructs [Server
Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions)
into "Forms and Mutations" and an API reference
- Removes content in place of future React API documentation pages
- Removes outdated [Building
Forms](https://nextjs.org/docs/pages/building-your-application/data-fetching/building-forms)
docs from the Pages Router and adds conditional content for both routes
in "Forms and Mutations"
- Adds TypeScript code blocks to API Routes page, recommends Route
Handlers for isomorphic signatures.
- Updates `revalidatePath` and `revalidateTag` docs to have a Server
Actions example.

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2023-08-25 14:31:11 -05:00
Lee Robinson
4e052deff2
docs: fix broken link missing leading slash (#54520) 2023-08-24 17:19:23 +00:00
Delba de Oliveira
94b7743cbe
Docs: Fix formatting issues in the rendering docs (#54517) 2023-08-24 16:49:46 +00:00
Delba de Oliveira
1dc5c066cb
docs: Rewrite Rendering Section and React Essentials Page (#51579)
We initially wrote the [React
page](https://nextjs.org/docs/getting-started/react-essentials) to
introduce Server Components in the App Router, but over time, some
implementation details have changed, and the information has become
stale. The React team is working on adding new docs, so I'd like to
change the narrative on the Next.js docs from "client vs. server
components" to "writing code for the server and for the client" - and
link back to the React documentation when it becomes available.

As React developers, we're very familiar with writing code for the
client, it's nice and simple. But doing so comes at the expense of not
being familiar with the server. The aim of these docs is to help
developers become proficient in both the client and server environments.

I'd like to take it back to the foundations, and not use abstractions
like SSG and CSR, MPAs or SPAs, as those terms come with their own set
of assumptions that make it harder to understand how RSC works. Instead,
we'll focus on the request lifecycle, show how application code flows
from the server to the client, and discuss the trade-offs of doing
operations in each environment.

- [x] Page: Rendering Fundamentals
   - [x] Environments: Client and Server
   - [x] Request-response lifecycle
   - [x] Network Boundary
- [x] Page: Server Components
    - [x] Benefits and use cases of server rendering
    - [x] How to use Server Components in Next.js
    - [x] How Server Components are rendered
    - [x] Static Rendering
    - [x] Dynamic Rendering
    - [x] Streaming
- [x] Page: Client Components
    - [x] Benefits and use cases of client rendering
    - [x] How to use Client Components in Next.js
    - [x] How Client Components are rendered
        - [x] Initial vs. Subsquent navigation
- [x] Page: Composition Patterns
    - [x] When to use client and server components
    - [x] Server Component Patterns
    - [x] Client Component Patterns
    - [x] Interleaving Client and Server Components
- [ ] ~Diagrams~ will follow up with new PR.
- [x] Set up redirects: https://github.com/vercel/front/pull/24917

---------

Co-authored-by: Térence Hollander <hollanderterence@gmail.com>
Co-authored-by: shawnthwei <32075290+shawnthwei@users.noreply.github.com>
Co-authored-by: Michael Novotny <manovotny@gmail.com>
2023-08-24 08:48:44 -05:00
Delba de Oliveira
0c85f8aad3
Docs: Add notes that revalidation is not available in the Edge runtime / only Node.js (#54338)
Fixes: https://vercel.slack.com/archives/C03S9JCH2Q5/p1692261964220369
2023-08-21 22:00:40 +00:00
Willi-m
baef523fb0
[Docs] fix missing ' in data-fetching/fetching-caching-and-revalidating (#54058)
In https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#opting-out-of-data-caching a single quote (`'`) is missing.

![CleanShot 2023-08-15 at 17 08 58](https://github.com/vercel/next.js/assets/179761/eccd5fc9-a2fd-4c11-968f-76fd33fc5317)
2023-08-15 14:12:56 +00:00
Shu Ding
10cb74062b
(docs) Fixes Server Actions example (#53920)
Closes #53910.
2023-08-11 18:25:31 +00:00
Lee Robinson
3077a0e9ff
docs: Add more information about Server Actions (#53805)
A few helpful additions based on conversations I've had recently.
2023-08-09 15:48:24 +00:00
Delba de Oliveira
8e0d108836
Docs: Add option for fetching data using route handlers - from the client (#53793)
In the data fetching page, we discuss the different ways you can fetch data in Next.js. This PR adds a fourth option which is to call route handlers from client components. I've also added a note that you shouldn't call a route handler from a server component. 

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-08-09 13:55:44 +00:00
Emilien Kenler
64d9475f37
Fix typo in data fetching documentation (#53772)
Fix a typo in data fetching documentation.
2023-08-09 04:45:49 +00:00
Tomoya Kashifuku
5f9d2c55ca
docs: fix the link to another document (#53599)
The link used to be "https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises" but actually "https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises.md" is correct (needs ".md" at the end)
2023-08-05 17:06:21 +00:00
José Olórtegui
49d4f8af3b
docs: update webhook snippet for cache revalidation (#53585)
This PR updates cache revalidation snippets in the docs. It seems that `res` should not be there since you can't find it anywhere in the snippet so I suppose that the intent was to use `NextResponse` instead. Another thing is that now we're checking the existence of the params so typescript doesn't get mad at us. And last I changed the methods to `POST` since AFAIK webhooks normally use the `POST` method.

Please let me know if there's anything left to do on my side.

Have a great day!

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-04 20:22:02 +00:00
Noam Honig
bf9c65f8d9
docs: fix force-dynamic example (#53521)
fixed force dynamic example

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-08-03 18:57:43 -04:00
Shu Ding
a58a869f48
(docs) Add example of redirection in Server Actions (#53485)
Based on the feedback from #53435, this PR adds an example of redirection inside Server Actions to the docs. Currently, we have examples of getting/setting cookies but there's nothing for `redirect()`.
2023-08-02 17:58:07 +00:00
Delba de Oliveira
b4d40f454e
Docs: Fix formatting issues in the caching docs (#53436) 2023-08-01 13:34:25 +00:00
Delba de Oliveira
98c3076eb4
Docs: Document caching mechanisms (#52514)
This PR document the caching semantics in Next.js, how they interact, and what APIs affect them. We're also taking the opportunity to consolidate terminology, remove duplicate content, and update sections of the docs that relate to caching. 

### Documentation

- [x] Create a new section for caching
- [x] Explain how the different caching mechanisms work
   - [x] Request Memoization (React Cache)
   - [x] Persistent Data Cache 
   - [x] Persistent Full Route Cache 
   - [x] In-memory, client-side Router Cache 
- [x] Document how different APIs affect caching
- [x] Document cache interactions 
- [x] Clean up stale information in the other docs sections
   - [x] Routing Section
      - [x] Move advanced navigation topics from fundamentals to **How Navigation Works** section
      - [x] Rewrite the **How Navigation Works** section
   - [x] Rendering Section
      - [x] Simplify fundamentals page
      - [x] Rewrite the **Static and Dynamic Rendering** pages
      - [ ] ~Create a page to explain how **Client and Server Components** are rendered~. Moved to this PR: https://github.com/vercel/next.js/pull/51579
   - [x] Data fetching section 
      - [x] Consolidate data fetching story for fetching, caching, and revalidating
      - [x] Clarify data fetching story with 3rd party libraries and React `cache`
      - [x] Create **Data Fetching Patterns** page
- [x] Document other related behaviors: 
   - [x] Update information on scroll position for back/forward navigation 
   - [x] Remove the concepts of **soft and hard navigation**
   - [x] Remove the concepts of **static and dynamic data fetching**
   - [x] Use consistent terminology **runtime** 👉🏼  **request time**. Runtime for Edge and Node.js, request time to describe when dynamic stuff happens
   - [x] `generateStaticParams` being able to seed the Full Route Cache
- [x] Polish 💅🏼 

---
### Related PRs:

- Diagrams: https://github.com/vercel/front/pull/24142
- Redirects: https://github.com/vercel/front/pull/24179
2023-07-31 17:03:26 +00:00