Commit graph

18873 commits

Author SHA1 Message Date
Michael Novotny
7e00d1871c
docs: Updates "No Before Interactive" error message for App router (#56033)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-27 10:54:17 -06:00
Shahriar
332bf6d4f8
docs: remove incorrect async components in parallel routes docs (#59966)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-27 10:45:14 -06:00
Dhaya
2c811af22e
examples: Upgrade with-algolia-react-instantsearch example to latest major version and use app router (#59961)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-27 10:44:32 -06:00
Mohammed Gadi
bc41a7f829
examples: Update .env.local.example of with-firebase (#59954) 2023-12-27 10:43:52 -06:00
Manu
02d390740b
docs: fix link to formEntries (#59935) 2023-12-27 10:42:17 -06:00
ash2048
6a23987282
docs: Fix typo in generate-sitemaps.mdx docs (#59964) 2023-12-27 10:40:51 -06:00
vercel-release-bot
fc25fcef3e v14.0.5-canary.28 2023-12-26 23:23:10 +00:00
Lee Robinson
7c7d981b2d
examples: progressive enhancement for Redis example (#59937)
The example had `useOptimistic` and wasn't structured so that the
browser could fall back to `action` if JS was still loading or disabled.
2023-12-25 20:07:13 -06:00
vercel-release-bot
247f9e8374 v14.0.5-canary.27 2023-12-25 23:21:49 +00:00
Michael H
eebad9c939
docs: Add media example for icon metadata (#56141)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-25 09:19:33 -06:00
Luke Schlangen
a0b661de8d
examples: remove broken deploy button (#58794) 2023-12-25 09:03:27 -06:00
vercel-release-bot
ebc4eaaa25 v14.0.5-canary.26 2023-12-24 23:21:31 +00:00
Jiachi Liu
365a0492d0
docs: fix prettier lint (#59918)
x-ref:
https://github.com/vercel/next.js/actions/runs/7315608759/job/19929482613

Closes NEXT-1928
2023-12-24 22:06:28 +01:00
Lee Robinson
0fc1d9e982
examples: update Redis to App Router (#59311) 2023-12-24 10:09:23 -06:00
Igor Varyvoda
d4b7c86ecf
docs: add Sirv loader for next/image (#57102)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-24 10:03:50 -06:00
Lee Robinson
142e7080a5
docs: clarify setting and reading cookies from Route Handlers (#59915)
Replaces https://github.com/vercel/next.js/pull/57052
2023-12-24 10:02:50 -06:00
vinay
3b64a53e59
docs: remove old links for examples (#57891)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-24 09:47:16 -06:00
Divine Quansah
ab16e51cf1
docs: fix import statement for next/og (#57810) 2023-12-24 09:45:21 -06:00
Harits Syah
768d2174eb
docs: add type to import statement (#57701) 2023-12-24 09:42:43 -06:00
vinay
ee4ff03828
docs: Add sensible name for cookie deleting functions (#57893) 2023-12-24 09:40:59 -06:00
Ahmed Abdelbaset
500a3f8f00
docs: fix typo (#59897) 2023-12-24 09:11:46 -06:00
vercel-release-bot
abcd10a039 v14.0.5-canary.25 2023-12-23 23:21:52 +00:00
Jiachi Liu
c4ba419d5c
Alias nextjs api entry to esm version for app router (#59852)
## What

When users specify `"type": "module"` in Next.js app, especially with
`create-next-app`, `Image` component is not working. An error
`Unsupported Server Component type: {...}` is thrown.

## Why

`next/image` API is mixing with a client component as default export and
a named export as server component. But the entry file of the API is
still CJS file, which will import the module as the object. So you'll
get `{ default, unstable_getImageProps }` when you do `import Image from
'next/image'` instead of `Image` component itself, where the CJS module
load all the exports as an object. This is expected behavior for ESM but
breaks the usage.

It only errors when you're using js extensions, if you're using
typescript, it still works. If you're using turbopack, it works in dev
mode.

This is also because webpack can't analyze the exports from CJS module
of that `next/image` entry file. Usually we can assign the default
export to the module itself, then attach other named exports onto it, so
the default export equals the `module.exports` itself. But for
`next/image` since the default export is an client component, doing that
will error with React as you cannot modify the react client reference.
Turbopack doesn't use the same way to analyze the default export, so it
doesn't have this problem.

## How

We create few ESM version of entry files of nextjs APIs, then pick up
them to let app router for bundling, instead of using the `next/<api
name>.js` CJS files. Those ESM entries still point to the `next/dist/..`
CJS files. In this way webpack and directly gets the exports from the
`next/dist/...` files and be aware of the module exports. No more CJS
module wrapping the ESM module, the default and named exports can
preserve correctly.

Fixes #54777
Closes NEXT-1774
Closes NEXT-1879
Closes NEXT-1923
2023-12-23 17:46:50 +01:00
Lee Robinson
3d9a1b481e
examples: add required env vars to auth example. (#59901) 2023-12-23 10:27:33 -06:00
Lee Robinson
4225da8cba
examples: Add new NextAuth.js example (#56914) 2023-12-23 10:21:26 -06:00
vercel-release-bot
c5b5b1e3a3 v14.0.5-canary.24 2023-12-22 23:22:32 +00:00
Nate Moore
2336274a2e
docs: Add cwd to VSCode debugging setup steps (#58689) 2023-12-22 16:26:04 -06:00
Ryo Matsukawa
7a18e6da37
docs: Rename React Query to TanStack Query (#59004) 2023-12-22 16:25:14 -06:00
Remco Haszing
34a5ef2189
docs: Mention remark-mdx-frontmatter in frontmatter docs (#59238) 2023-12-22 16:23:28 -06:00
Lisa Ferguson
b57a2c809d
docs: fix TS code snippet for MDX example (#57988) 2023-12-22 16:22:46 -06:00
Michael Novotny
f999d639b0
docs: Updates references for styled-components configuration in next.config.js (#59495) 2023-12-22 16:21:41 -06:00
Steven Kamwaza
19dac217b6
docs: fix not-found file paths (#59478) 2023-12-22 16:18:27 -06:00
Yeseul, Kim
c7b2422046
docs: Add Chakra UI setup guide (#59275) 2023-12-22 16:16:27 -06:00
Loris Sigrist
19eea58d69
docs: Remove typesafe-i18n from third-party i18n options (#59624) 2023-12-22 16:14:25 -06:00
James Burgess
1529b50af6
docs: correct type in sitemap.mdx (#59787) 2023-12-22 16:09:59 -06:00
Rajdeep singh
3e26253c31
docs: add version history for unstable_cache (#59799) 2023-12-22 16:09:32 -06:00
minaelee
a3fb38a475
docs: Minor grammar edits (#59887)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-22 16:08:33 -06:00
minaelee
2d50879f0f
docs: fix run-on and definition of trailing slash redirect (#59889) 2023-12-22 16:05:23 -06:00
Zack Tanner
6545783be3
fix router prefetch cache key to work with route interception (#59861)
### What?
When handling route interception in two different segments but handled
by the same interception route, the first interception will show the
correct component but attempting the same interception on another
segment will return elements from the first request, not the second.

### Why?
Prefetch cache entries are created from the browser URL. However, route
interception makes use of `nextUrl` to mask the underlying components
that are being fetched from the server to handle the request

Consider the following scenario:

```
app
   foo
     @modal
       (...)post
         [id]
   bar
     @modal
       (...post)
         [id]
   post
     [id]
     
```
If you trigger an interception on `/foo`, your URL is going to be masked
to `/post/1` and keyed as such in the prefetch cache. However, the cache
entry is actually associated with `app/foo/@modal/(...post)/[id]`. That
means when you trigger the same interception on `/bar`, it will return
the tree from `/foo`.

### How?
This PR will prefix the prefetch cache key with `state.nextUrl` when
necessary.

Fixes #49878
Fixes #52748
Closes NEXT-1818
2023-12-22 13:10:37 -08:00
Zack Tanner
c4adae89b1
fix parallel catch-all route normalization (#59791)
### What?
Catch-all routes are being matched to parallel routes which causes
issues like an interception route being handled by the wrong page
component, or a page component being associated with multiple pages
resulting in a "You cannot have two parallel pages that resolve to the
same path" build error.

### Why?
#58215 fixed a bug that caused catchall paths to not properly match when
used with parallel routes. In other words, a catchall slot wouldn't
render on a page that could match that catch all. Or a catchall page
wouldn't match a slot. At build time, a normalization step was
introduced to take application paths and attempt to perform this
matching behavior.

However in it's current form, this causes the errors mentioned above to
manifest. To better illustrate the problem, here are a few examples:

Given:
```
{
  '/': [ '/page' ],
  '/[...slug]': [ '/[...slug]/page' ],
  '/items/[...ids]': [ '/items/[...ids]/page' ],
  '/(.)items/[...ids]': [ '/@modal/(.)items/[...ids]/page' ]
}
```

The normalization logic would produce:
```
{
  '/': [ '/page' ],
  '/[...slug]': [ '/[...slug]/page' ],
  '/items/[...ids]': [ '/items/[...ids]/page' ],
  '/(.)items/[...ids]': [ '/@modal/(.)items/[...ids]/page', '/[...slug]/page' ]
}
```
The interception route will now be improperly handled by
`[...slug]/page` rather than the interception handler.

Another example, which rather than incorrectly handling a match, will
produce a build error:

Given:
```
{
  '/': [ '/(group-b)/page' ],
  '/[...catcher]': [ '/(group-a)/@parallel/[...catcher]/page' ]
}
```

The normalization logic would produce:

```
{
  '/': [ '/(group-b)/page', '/(group-a)/@parallel/[...catcher]/page' ],
  '/[...catcher]': [ '/(group-a)/@parallel/[...catcher]/page' ]
}
```
The parallel catch-all slot is now part of `/`. This means when building
the loader tree, two `children` parallel segments (aka page components)
will be found when hitting `/`, which is an error.

The error that was added here was originally intended to help catch
scenarios like:
`/app/(group-a)/page` and `/app/(group-b)/page`. However it also throws
for parallel slots, which isn't necessarily an error (especially since
the normalization logic will push potential matches).

### How?
There are two small fixes in this PR, the rest are an abundance of e2e
tests to help prevent regressions.

- When normalizing catch-all routes, we will not attempt to push any
page entrypoints for interception routes. These should already have all
the information they need in `appPaths`.
- Before throwing the error about duplicate page segments in
`next-app-loader`, we check to see if it's because we already matched a
page component but we also detected a parallel slot that would have
matched the page slot. In this case, we don't error, since the app can
recover from this.
- Loading a client reference manifest shouldn't throw a cryptic require
error. `loadClientReferenceManifest` is already potentially returning
undefined, so this case should already be handled gracefully

Separately, we'll need to follow-up on the Turbopack side to:
- Make sure the duplicate matching matches the Webpack implementation (I
believe Webpack is sorting, but Turbopack isn't)
- Implement #58215 in Turbopack. Once this is done, we should expect the
tests added in this PR to start failing.

Fixes #58272
Fixes #58660
Fixes #58312
Fixes #59782
Fixes #59784

Closes NEXT-1809
2023-12-22 09:30:23 -08:00
vercel-release-bot
b3ad907d2b v14.0.5-canary.23 2023-12-21 15:59:57 +00:00
Andrew Clark
b83e0f5843
[PPR Navs] Bugfix: Dynamic data never streams in if prefetch entry is stale (#59833)
Adds a regression test and a fix for a bug that sometimes happens when a
prefetched route on the client becomes stale — the app would get stuck
in a loading state.

The problem was the condition I used to fallback to the non-PPR
implementation, inside navigateReducer. It was too narrow, causing
prefetched segments that contained dynamic holes to sometimes be treated
as if they were complete. The net effect was that the dynamic data would
never stream in, and the page would get stuck in a fallback state until
the stale prefetch was eventually purged from the cache, or the user
refreshed the page.

The reason the mistake happened was, as an incremental step, I decided
to fallback to the non-PPR implementation for any case where I hadn't
yet implemented the equivalent functionality. I think still think this
is a good strategy, despite the mistake, but I'm eager to get everything
migrated to the new model as soon as possible.


Closes NEXT-1920
2023-12-21 07:49:30 -08:00
Jiachi Liu
14052c052e
Upgrade og dependencies (#59541)
Upgrade `@vercel/og` to 0.6.1

Closes NEXT-1857
2023-12-21 14:50:57 +01:00
JJ Kasper
75a8303f1b
Add unstable_cache validate test case (#59828)
Follow-up to https://github.com/vercel/next.js/pull/59822 adding an
additional test case.

Closes NEXT-1918
2023-12-20 18:00:23 -06:00
Jiachi Liu
8a1717cb8a
Rename confusing loaders (#59827)
We already have variables of swc loaders for different bundling layers,
the composed one should just be loaders instead of being called "swc
loader"

Closes NEXT-1917
2023-12-21 00:55:13 +01:00
JJ Kasper
1affa75a19
Update error check in validateRevalidate (#59826)
Applies
https://github.com/vercel/next.js/pull/59822#discussion_r1433267299

Closes NEXT-1916

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-12-20 17:47:44 -06:00
vercel-release-bot
7a2db94d47 v14.0.5-canary.22 2023-12-20 23:22:10 +00:00
JJ Kasper
12d2a6f3b1
Ensure we validate revalidate configs properly (#59822)
If a user accidentally configures a non-valid `revalidate` value this
ensures we show a proper error message instead of silently tolerating
it.

Closes: NEXT-1896

Closes NEXT-1915
2023-12-20 17:16:35 -06:00
vercel-release-bot
4402428c35 v14.0.5-canary.21 2023-12-20 21:33:46 +00:00
Leah
16e3f537ec
fix(turbopack): prevent edge entrypoint from becoming an async module (#59818)
### Why?

We can't await the entrypoint of the edge bundle, so it has to not be
async.

Closes PACK-2171
2023-12-20 20:12:11 +00:00