Commit graph

1791 commits

Author SHA1 Message Date
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
Steven
a3aa6590ff
chore(next/image)!: mark domains as deprecated in favor remotePatterns (#57062)
We already had `domains` as "not recommended" but this PR marks it as "deprecated" and prints a warning if its detected.

I also updated all examples to switch from `domains` to `remotePatterns`.
2023-10-19 20:24:48 +00:00
Jiachi Liu
a3e56c9c1e
Move ImageResponse to next/og (#56662)
### Story

Since we introduced `ImageResponse` into `next/server` export, there're a few libraries relying on `next/server` that accidentally ended up with bundling og image into the bundle. As og package is quite large that could easily raise the size concern for middleware, edge runtime routes.

### Struggles
 We've done optimizations. The tree-shaking strategies are tricky, we tried modularize imports and also optimize cjs require/exports to make sure you're not including og package into bundle if it's not being used. However, it's still not 100% can handle all the bundle optimization cases, such as `import {..} from "next/server.js"` could also ended up with the cjs bundle that failed the tree-shaking.

### Move on
So we decide to move og `ImageResponse` into a separate export `next/og`

Closes NEXT-1660
2023-10-19 14:26:48 +00:00
Steven
27b89e4aaf
chore(docs): fix missing fallback on next/image sizes example (#56718)
This example use of `sizes` was missing the fallback.

Its best to review with [`?w=1`](https://github.com/vercel/next.js/pull/56718/files?w=1)
2023-10-18 17:55:46 +00:00
Steven
3a459ca986
chore(next/image)!: mark onLoadingComplete as deprecated in favor of onLoad (#56944)
## History

We used to pass `onLoad` through directly to the underlying img so `onLoadingComplete` was introduced in order to handle the case when `placeholder="blur"` was used and `onLoad` would trigger before the placeholder was removed.

We have since changed the behavior of `onLoad` so that it acts the same as `onLoadingComplete` and therefore `onLoadingComplete` is no longer needed.

## What is this PR doing?

This PR marks `onLoadingComplete` as deprecated in favor of `onLoad`. In the future, we may remove `onLoadingComplete`.
2023-10-17 21:12:22 +00:00
Juan Martín Seery
308a327923
feat(env): upgrade dotenv (#38481)
Upgraded dotenv to v16. Breaking changes are:

- Multiline parsing support
- Support inline comments
- Backtick support

[See their changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`


Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2023-10-17 00:57:51 +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
Dmitriy Glazkov
26d0bf27fb
Update 05-mdx.mdx . Fix key of the prop (#56883)
Fix key of the prop

Also the same key prop we can find in `next-mdx-remote` [example with getStaticProps](https://github.com/hashicorp/next-mdx-remote#typescript)
2023-10-16 22:21:44 +00:00
Balázs Orbán
1ff7f07875
feat: drop Node.js 16 (#56896)
### What?

BREAKING CHANGE: Bump the minimum required Node.js version.

### Why?

Node.js 16 has reached end-of-life in September.

Bumped to `18.18.2` since it contained some security-related patches: https://nodejs.org/en/blog/vulnerability/october-2023-security-releases

### How?

Bumped `engines` where needed, upgraded the workflows.

This will allow us to remove quite a few polyfills, I'll open separate PRs for those.
2023-10-16 21:41:38 +00:00
Joris Tirado
21fadd3358
Fix typo (#56863) 2023-10-15 17:18:00 +00:00
Diana Gouveia
db188e480f
docs: fix cypress script typo in 10-testing.mdx (#56765)
fix cypress script name typo to run `cypress:open` as declared on package.json script example
2023-10-14 22:43:32 +00:00
VAS
14aeb49662
Update supported-browsers.mdx (#56815)
Fixed a typo -
docs/04-architechture/supported-browsers.mdx

Changes(s) made -
Fixed a typo for improving clarity
[includes -> include]
'your dependencies includes' -> 'your dependencies include'

Please review and merge it.
2023-10-13 21:04:49 +00: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
Balázs Orbán
6fdba20b6d
docs: fix typo in Update 02-get-static-paths.mdx (#56757)
Fix typo in docs

Fixes #56741

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-10-12 12:18:20 -04:00
Delba de Oliveira
b6cce9ce5e
Docs: Add missing description field (#56749)
Fixing error in next-site due to empty description field.
2023-10-12 08:16:06 -05:00
Farsab
1c07848297
fix(docs): adjust api route documentation examples (#56660)
Fixed the example functions in the documentation to use `async` in order to use `await` within the function body. 

Co-authored-by: Michael Novotny <446260+manovotny@users.noreply.github.com>
2023-10-10 15:23:00 +00:00
Krishnanand Yadav
f6d6acd9ec
Update 01-contribution-guide.mdx: Fix a typo (#56665)
Fix a small typo in the metadata section of the contributing guide.

Kindly add the label: `hacktoberfest-accepted`.
2023-10-10 15:15:13 +00:00
Chris Britten
c8064d69f6
docs(router): clarify dynamic route slug is about a file name, not "folder" (#56596)
### What?

Update documentation on dynamic routing to clarify the use of segment names within file names, rather than referring to them as "folder names".

### Why?

The original documentation used the example term `folderName` when it was referencing dynamic segment names within filenames.  The paths being described here are file names but not folders, and end in a file extension.  This could confuse readers and developers, especially those new to Next.js, leading to potential misunderstandings and misconfigurations.  Perhaps folderName was a relic of a different example wrapping a folder name to do a nested path or other configuration?  But here it seems out of place.

### How?

- Reviewed the provided documentation sections on dynamic routing.
- Replaced references to "folderName" with a different term "segmentName". 
- Ensured the examples provided in the documentation correctly showcase the use of segment names within filenames.
2023-10-10 00:03:49 +00:00
JoRyGu
3f25a2e747
clarify client components render on server on full page load (#55469)
IMO there is not enough of an indicator that client components render on the server on full page loads towards the top of the documentation page. I've seen plenty of experienced devs totally miss this critical info and get stuck on a problem due to a lack of understanding. Putting at least some kind of indicator above the fold would help with that.




Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-10-09 14:39:24 +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
jazsouf
82c095f8c2
docs: add missing word (#56547)
small typo




Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-10-07 00:23:09 +00:00
Viktor
2c5a8b1abb
Update redirect.mdx (#56414)
Add link to streaming doc
2023-10-04 13:01:10 +00:00
Michael Novotny
f77f222d4f
Updates MDX docs (#56378)
When trying to update my own website to use App Router, I found the current Next.js Docs were missing specifics to get it working (most notably, no mention of `pageExtensions`). Coupled with community feedback, we decided to revisit and rework the entire page.

The page has been walked through and tested on brand new create-next-app projects for both App and Pages Routers to ensure completeness.

Closes [DX-2095](https://linear.app/vercel/issue/DX-2095/improve-nextjs-mdx-docs)

Rendered pages while running locally, in case they are more helpful in seeings the changes and different between routers.

### App Router 

![localhost_3332_docs_pages_building-your-application_configuring_mdx (1)](https://github.com/vercel/next.js/assets/446260/2a2b1a66-c794-4831-ab89-a6a61d02eb84)

### Pages Router

![localhost_3332_docs_pages_building-your-application_configuring_mdx](https://github.com/vercel/next.js/assets/446260/cc60a8a2-a931-4033-aaba-e989a719692d)
2023-10-03 19:32:58 +00:00
Syphini
ef440d40b6
add digest property to error prop (#56339)
Matching the conventions laid out in https://nextjs.org/docs/app/api-reference/file-conventions/error
2023-10-03 14:21:30 +00:00
Daigo Shitara
5254aaecf6
Update image.mdx (#56266)
fix link

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-10-02 14:29:18 +00:00
Daigo Shitara
0d4859b247
Update image.mdx (#56269)
add closing `'`.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-10-02 14:06:23 +00:00
Qing
c20e21bd38
fix: @libsql/client build error (#56192)
Here is the error when building @libsql/client:
<img width="794" alt="image" src="https://github.com/vercel/next.js/assets/7880675/7ec63918-04e1-4468-b552-0aba7225b745">

Here is the [codesandbox](https://codesandbox.io/p/sandbox/nice-feynman-hwjsyd?file=%2Fapp%2Fapi%2Froute.ts%3A8%2C7) to repro it.

Enable the `serverComponentsExternalPackages` the issue will be gone:
<img width="766" alt="image" src="https://github.com/vercel/next.js/assets/7880675/af014f2f-2ab2-4ab7-9e3e-4d4adbae36be">

This PR just adds it to the default package list, so Next.js developers don't have to add it manually.



Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2023-09-29 13:22:38 +00:00
boylett
769d27aacc
correcting link to useSearchParams ref (#56169)
The link to the useSearchParams ref within the File Conventions > layout.js page currently links to the useParams ref, which is wrong and may lead to confusion as the useParams and useSearchParams APIs operate differently.
2023-09-28 23:11:33 +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
Shu Ding
fe90b04f95
(docs) Document Server Actions .bind method (#56164)
This will be the recommended way of passing extra arguments to a Server Action. A couple of reasons behind:

- This is better than putting a hidden `<input hidden value={userId}/>` because that will appear in the SSR'd HTML as full text and cannot be encoded. With `.bind`, we can handle that in the future.
- This is better than event callbacks `onSubmit={(e) => { await updateUser(userId, e.target.formData) }}` as this supports progressive enhancement.
- This is better than re-creating a new action `action={async (formData) => { "use server"; return updateUser(userId, formData) }}` as inlined `"use server"` only works in Server Components.
2023-09-28 16:20:53 +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
walker flynn
8f3eb01193
Update revalidatePath.mdx to fix confusing wording of arguments section. (#56099)
This part of the documentation was confusing and did not match the below examples.
2023-09-28 01:11:00 +00:00
Vũ Văn Dũng
cf3d73a46b
Add the default import alias to create-next-app prompt for clarity (#55896)
### Why?

Whenever I run `create-next-app` and reach this question

```
Would you like to customize the default import alias? No / Yes
```

I always have to select "No", because I don't remember what this default import alias here is. [It _is_ documented to be `@/*`](https://nextjs.org/docs/app/api-reference/create-next-app#non-interactive), but the documentation is relatively hidden and not many people know about it – it's also easy to forget.

Even more confusingly, the next question ("What import alias would you like configured?") doesn't have this `@/*` as the default answer, but the user's last choice as the default answer instead (which could be different from `@/*` – making people wonder if Next.js changed their defaults overnight).

I suppose it would be better to just make it clear in the prompt itself, so people with skill issues who happen to forget that default value (like me) can still confidently select "Yes" if they want `@/*`, without having to do "No" and manually type `@/*` again.

### How

```diff
- Would you like to customize the default import alias?
+ Would you like to customize the default import alias (@/*)?
```
2023-09-26 22:58:46 +00:00
MUTESA Cedric
730b43d0ce
docs: link from install docs to create-next-app-docs (#55909)
as many developers are moving to bun, its a good idea that it also be included as an installation method.



Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-09-26 15:28:56 +00:00
Martyanov Andrey
9e9e366865
docs: pass base headers while setting nonce (#55708)
Example for setting "nonce", when created, clears the passed headers
2023-09-26 15:12:13 +00:00
water
ed6e8010e4
Update 02-project-structure.mdx (#55940)
Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2023-09-26 10:08:55 +00:00
Lee Robinson
0e61aa99a2
docs: Add Stytch auth provider (#55777) 2023-09-25 21:41:38 -05: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
Abdulghane Jesry
1d86a092ad
Update 03-linking-and-navigating.mdx (#55969)
I've removed a duplicated example.
2023-09-25 18:03:24 +00:00
Matthew Martinez
3dc2c1c7f8
docs-55629 update router cache column in cache interactions api table (#55630)
Fixes https://github.com/vercel/next.js/issues/55629.

Updates the `Router cache` column in the [Cache Interactions API Table](https://nextjs.org/docs/app/building-your-application/caching#apis) to reflect `Revalidate (Server Action)` in the `revalidateTag`, `revalidatePath` and `cookies` rows when used in a Server Action.
2023-09-25 17:48:30 +00:00
3λiȯ+
9d86c1224c
docs: Correct place for passing extension option to createMDX() (#55967)
### What?

Fixing a little mistake in the documentation, where the placement of the `extension` option for `createMDX()` was described as being inside the `options` property:

```ts
const withMDX = createMDX({
  options: {
    extension: /\.mdx?$/,
```

But it's actually a property of its own:


```ts
const withMDX = createMDX({
  extension: /\.mdx?$/,
```

I confirmed that the latter is correct because:

- It solves an issue I was having: Unable to import `.md` files
- On the same docs page, there's another place where it mentions this `extension` option and the code example is correct there
- The option is described in a similar issue, such as https://github.com/vercel/next.js/issues/45431#issuecomment-1410363864
2023-09-25 17:38:01 +00:00
Radu Petre Tarean
fb551c90e7
Update 03-linking-and-navigating.mdx (#55907)
I hope this is right, the description said for a link to be active the pathname should match the href, sorry if its wrong
2023-09-25 17:11:47 +00:00
Deepa Subramanian
9e3c1829b0
docs: add not-found to file conventions page (#55944)
Issue: https://github.com/vercel/next.js/issues/53888

Added "not-found.js" information to error.mdx after the `global-error.js`. Please approve.




Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-09-25 15:06:01 +00:00
Vũ Văn Dũng
0b74f51882
docs: Add example on query parameters in route handlers (#55789)
### Why?

There is already an example of handling query parameters (`searchParams`) in route handler, but it's quite hidden (in [Opting out of caching](https://nextjs.org/docs/app/building-your-application/routing/route-handlers#opting-out-of-caching)). It made it hard for many developers to figure out how to do that: [there](https://discord.com/channels/752553802359505017/1127781032242974790) [are](https://discord.com/channels/752553802359505017/752647196419031042/1143181251856044042) [several](https://discord.com/channels/752553802359505017/752647196419031042/1146007247630106704) [people](https://discord.com/channels/752553802359505017/752647196419031042/1154623267164917861) who couldn't find that section in the documentation. (Linked are messages in the Next.js Discord server.)

Therefore this PR adds an example to the route handler documentation on how to do that, so developers can take reference more easily.
2023-09-24 15:23:40 +00: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
João de Vasconcelos
3b8bbe197f
Fix missing async keyword in function declaration (#55887)
Just a one word change to fix the example in https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#generate-images-using-code-js-ts-tsx
2023-09-24 01:54:38 +00:00
Dom Sip
814db26c9c
Revert "fix typo in API Reference - Image Component" (#55889)
Currently the image props section is broken:
https://nextjs.org/docs/pages/api-reference/components/image



Reverts vercel/next.js#55776

fixes: [#55869](https://github.com/vercel/next.js/issues/55869)
2023-09-23 22:30:26 +00:00
Deepa Subramanian
d5db4d366c
Update 10-testing.mdx (#55801)
Made changes as suggested by the reporter. 

```json filename="tsconfig.json or jsconfig.json"
{
  "compilerOptions": {
    "module": "esnext",
    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "@/components/*": ["components/*"]
    }
  }
}
```

```json filename="package.json"
{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "cypress:open": "cypress open"
  }
}
```
2023-09-23 01:11:46 +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