While the React Compiler is still in beta, this functionality was not
yet documented. I also updated this to remove the 15 RC since 15 is now
stable.
Co-authored-by: Sam Ko <[email protected]>
Reverts vercel/next.js#72988
Right now, we're focused on making sure the examples linked are
guaranteed to work and placed inside the Next.js community GitHub
organization.
### Overview
This PR removes the `geo` and `ip` properties from `NextRequest` for
Next.js 15. These values had to be provided by your hosting provider.
Since this feature was not generally useful for the broader Next.js
community (outside of Vercel), we feel it makes more sense to keep this
as a Vercel-specific feature and not something built into the framework.
### Alternatives
If you are using Vercel, you can alternatively use the `geolocation` and
`ipAddress` functions from
[`@vercel/functions`](https://vercel.com/docs/functions/vercel-functions-package)
instead:
```js filename="middleware.ts"
import { geolocation, ipAddress } from '@vercel/functions';
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
const { city } = geolocation(request);
const ip = ipAddress(request)
// ...
}
```
---------
Co-authored-by: Eng Zer Jun <[email protected]>
This adds a guide explaining how to create a PWA with the Next.js App
Router. This includes support for push notifications, installing the app
to your home screen, using a service worker, and more.
We recently merged and combined the RC docs into the main docs, so there
is a single codebase. This added new icons and callouts for parts of
Next.js that are experimental or in a canary release.
However, this gets a little tricky with React 19. There have been
changes to `useFormState` and `useFormStatus` which differ from the
latest v14.x release and 15 + React 19 RC.
As 14 is still the stable release, we need to default to showing
`useFormState` and add proper callouts for those on canary/RC. I also
added more details to the upgrade guide for v15.
This updates the data fetching, caching, and revalidating pages to use a
more standardized template. There is also now more direct, concise
examples and code snippets. Finally, I broke out "revalidating" into a
new ISR page, to better match the terms people are searching for.
To reduce the number of files cloned during `create-next-app`, this PR
shifts the SVG assets placed in the `public/` folder to instead by
consumed from the Next.js site.
Since these are SVG files (vector images), the Image component does
_not_ optimize them with image optimization. Image optimization only
applies to raster images (like `.png` or `.jpg`). This means it's
effectively similar to using the `unoptimized` prop on the `Image`
component, which means you don't need to add `remotePatterns` to
`next.config.js` – which would be midly annoying for the
`create-next-app` starter.
I also renamed `file-text.svg` to `file.svg` so the URL is shorter.
These assets will be live on .org any minute now.
We've seen too many instances of folks accidentally committing their
`.env` files that I feel it's time to make this change.
Up until now, Next.js has recommended that you use `.env.local` when
working locally to store your environment variables. Some developers do
intentionally want to commit their `.env` file without secret values to
source control. However, the ecosystem is fragmented on `.local`
support.
There are tools which require secrets values that do _not_ support
`.local` and require using `.env`. This means that it's possible to dump
your secret values into a `.env` file and commit to source control,
thinking that the defaults would have you covered.
This change updates the defaults for `create-next-app` to ignore all
`.env` files by default. If you want to commit then, you opt-in by
modifying your `.gitignore`, versus the opposite.
Related: https://x.com/complexlity/status/1755890800527892716
---------
Co-authored-by: Sam Ko <[email protected]>
This PR stabilizes the previously introduced experimental config options
for providing a custom cache handler (for both ISR as well as the Data
Cache) and for disabling or configuring the in-memory cache size. The
example usage would be as follows:
```js
// next.config.js
module.exports = {
cacheHandler: require.resolve('./cache-handler.js'),
cacheMaxMemorySize: 0 // disable default in-memory caching
}
```
This PR also updates the documentation to better reflect how to use the
custom cache handler when self-hosting. Further information will be
added in a following PR that also includes a full example of a custom
cache handler that implements `revalidateTag` as well as passing in
custom cache tags. The API reference docs have been updated here, as
well as a version history added.
I also noticed that we currently have two duplicated versions of the ISR
docs in the Pages Router docs: both for rendering and for data fetching.
Data Fetching is the correct location for this page. There were no other
references to the rendering version in the docs, so that must have been
an accident. I'll need to a get a redirect going for that regardless.
Tests have been updated for `cacheHandler` and I added a new test for
`cacheMaxMemorySize`.
---------
Co-authored-by: Jiachi Liu <[email protected]>
- Remove `experimental_` import for `useFormStatus`
- Update all dependencies
- Move to `postgres` so it works with any Postgres provider
- Fix a TypeScript issue
- Use `next dev --turbo`
Based on feedback from https://github.com/vercel/next.js/issues/47793, I
made some improvements around the geolocation docs. Specifically around
`request.ip`, `request.geo`, and how to access these values. I noticed
there was a bit of a divergence, as some of the `NextRequest` and
`NextResponse` docs were split out for the App Router section, but not
all.
This PR finishes that swing by removing the previous catch-all for
`next/server` in the Pages Router docs and splits them into individual
docs pages.
Wrote a lil' thread about this:
https://twitter.com/leeerob/status/1736543599339172121
---------
Co-authored-by: Delba de Oliveira <[email protected]>