Commit graph

1621 commits

Author SHA1 Message Date
Balázs Orbán
9477b61b51
fix(next): clarify fetch polyfill, drop node-fetch (#53548)
### What?

Fix documentation about `fetch` polyfilling, and drop `node-fetch` references.

### Why?

Since we stopped using `node-fetch` in `next` in favor of `undici` there were some inconsistencies in the docs, and unused references to the `node-fetch` package inside `packages/next`-


Noted this while answering this [Slack thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1691089801007129)
2023-08-03 23:12:26 +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
Robert Bradford
f08d42d533
docs: Fix typo and link in 02-app-router-migration.mdx (#53537)
Fixes a typo and a missing closing parenthesis on a link.
2023-08-03 22:50:01 +00:00
Jakub Naskręski
754a2a6ad8
docs: Remove duplicate backtick in next/font (#53520)
Fixed duplicate backtick in
[adjustFontFallback](https://nextjs.org/docs/pages/api-reference/components/font#adjustfontfallback:~:text=false%3A%20for-,%60%60next/font/google%60,-adjustFontFallback%3A%20%27Times%20New)
API docs.
2023-08-03 16:56:54 -04:00
Jacob Pargin
e30f6f4530
Fix markdown for caching doc link (#53536)
☝️  Just that!
2023-08-03 17:11:37 +00:00
OJ Kwon
630c41cd92
feat(next): next info --verbose for additional details (#53181)
### What?

First phase implementation for WEB-1313.

This PR expands existing `next info` features by adding new flag `--run-diags`. When this flag is supplied, next.js will try to collect more information. Primarily informations are related to next-swc installation to see if it's possible to diagnose why next-swc cannot be loaded on certain systems. It is not a definitive list - depends on the findings we may increase more items to collect.

These are the list of status included in the output

- Host info: CI / WSL / Docker
- Next.js installation: node, pkg mger version, next.js pkg
- Partial Node.js diagnostics report: `header, javascriptHeap, sharedObjects`
- next-swc installation: check if installed next-swc can be loaded
- (Mac os only) next-swc shared object dependencies: using `otool` or `dyld_info` to collect binary dependencies. Linux / Windows support will follow later.

Below's an example generated report, expect user to attach into issue if there are failures. 

<details>

```
### Host system information


  WSL: false
  Docker: false
  CI: false


### Next.js installation


  Binaries:
    Node: 18.11.0
    npm: 8.19.2
    Yarn: N/A
    pnpm: 7.24.3
  Relevant Packages:
    next: 13.4.13-canary.1
    eslint-config-next: 13.4.13-canary.1
    react: 18.2.0
    react-dom: 18.2.0
    typescript: 5.1.3
  Next.js Config:
    output: N/A



### Node.js diagnostic report

{
  "header": {
    "reportVersion": 2,
    "event": "JavaScript API",
    "trigger": "GetReport",
    "filename": null,
    "dumpEventTime": "2023-07-25T14:13:32Z",
    "dumpEventTimeStamp": "1690319612854",
    "processId": 33203,
    "threadId": 0,
    "nodejsVersion": "v18.11.0",
    "wordSize": 64,
    "arch": "arm64",
    "platform": "darwin",
    "componentVersions": {
      "node": "18.11.0",
      "v8": "10.2.154.15-node.12",
      "uv": "1.43.0",
      "zlib": "1.2.11",
      "brotli": "1.0.9",
      "ares": "1.18.1",
      "modules": "108",
      "nghttp2": "1.47.0",
      "napi": "8",
      "llhttp": "6.0.10",
      "openssl": "3.0.5+quic",
      "cldr": "41.0",
      "icu": "71.1",
      "tz": "2022b",
      "unicode": "14.0",
      "ngtcp2": "0.8.1",
      "nghttp3": "0.7.0"
    },
    "release": {
      "name": "node",
      "headersUrl": "https://nodejs.org/download/release/v18.11.0/node-v18.11.0-headers.tar.gz",
      "sourceUrl": "https://nodejs.org/download/release/v18.11.0/node-v18.11.0.tar.gz"
    },
    "osName": "Darwin",
    "osRelease": "22.5.0",
    "osVersion": "Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000",
    "osMachine": "arm64"
  },
  "javascriptHeap": {
    "totalMemory": 25624576,
    "executableMemory": 1048576,
    "totalCommittedMemory": 23543808,
    "availableMemory": 4324923368,
    "totalGlobalHandlesMemory": 16384,
    "usedGlobalHandlesMemory": 8384,
    "usedMemory": 20296720,
    "memoryLimit": 4345298944,
    "mallocedMemory": 1431256,
    "externalMemory": 1450294,
    "peakMallocedMemory": 6525792,
    "nativeContextCount": 1,
    "detachedContextCount": 0,
    "doesZapGarbage": 0,
    "heapSpaces": {
      "read_only_space": {
        "memorySize": 0,
        "committedMemory": 0,
        "capacity": 0,
        "used": 0,
        "available": 0
      },
      "old_space": {
        "memorySize": 8994816,
        "committedMemory": 9175040,
        "capacity": 8830992,
        "used": 8829704,
        "available": 1288
      },
      "code_space": {
        "memorySize": 966656,
        "committedMemory": 917504,
        "capacity": 765440,
        "used": 762496,
        "available": 2944
      },
      "map_space": {
        "memorySize": 802816,
        "committedMemory": 1048576,
        "capacity": 773376,
        "used": 773264,
        "available": 112
      },
      "large_object_space": {
        "memorySize": 6094848,
        "committedMemory": 6094848,
        "capacity": 6056016,
        "used": 6056016,
        "available": 0
      },
      "code_large_object_space": {
        "memorySize": 0,
        "committedMemory": 0,
        "capacity": 0,
        "used": 0,
        "available": 0
      },
      "new_large_object_space": {
        "memorySize": 376832,
        "committedMemory": 376832,
        "capacity": 4995992,
        "used": 351088,
        "available": 4644904
      },
      "new_space": {
        "memorySize": 8388608,
        "committedMemory": 5931008,
        "capacity": 4123904,
        "used": 3524152,
        "available": 599752
      }
    }
  },
  "sharedObjects": [
    "/Users/ojkwon/Library/Application Support/fnm/node-versions/v18.11.0/installation/bin/node",
    "/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation",
    "/usr/lib/libobjc.A.dylib",
    "/System/Library/PrivateFrameworks/CoreServicesInternal.framework/Versions/A/CoreServicesInternal",
    "/usr/lib/liboah.dylib",
    "/usr/lib/libfakelink.dylib",
    "/usr/lib/libicucore.A.dylib",
    "/usr/lib/libSystem.B.dylib",
    "/System/Library/PrivateFrameworks/SoftLinking.framework/Versions/A/SoftLinking",
    "/usr/lib/libc++abi.dylib",
    "/usr/lib/libc++.1.dylib",
    "/usr/lib/system/libcache.dylib",
    "/usr/lib/system/libcommonCrypto.dylib",
    "/usr/lib/system/libcompiler_rt.dylib",
    "/usr/lib/system/libcopyfile.dylib",
    "/usr/lib/system/libcorecrypto.dylib",
    "/usr/lib/system/libdispatch.dylib",
    "/usr/lib/system/libdyld.dylib",
    "/usr/lib/system/libkeymgr.dylib",
    "/usr/lib/system/libmacho.dylib",
    "/usr/lib/system/libquarantine.dylib",
    "/usr/lib/system/libremovefile.dylib",
    "/usr/lib/system/libsystem_asl.dylib",
    "/usr/lib/system/libsystem_blocks.dylib",
    "/usr/lib/system/libsystem_c.dylib",
    "/usr/lib/system/libsystem_collections.dylib",
    "/usr/lib/system/libsystem_configuration.dylib",
    "/usr/lib/system/libsystem_containermanager.dylib",
    "/usr/lib/system/libsystem_coreservices.dylib",
    "/usr/lib/system/libsystem_darwin.dylib",
    "/usr/lib/system/libsystem_dnssd.dylib",
    "/usr/lib/system/libsystem_featureflags.dylib",
    "/usr/lib/system/libsystem_info.dylib",
    "/usr/lib/system/libsystem_m.dylib",
    "/usr/lib/system/libsystem_malloc.dylib",
    "/usr/lib/system/libsystem_networkextension.dylib",
    "/usr/lib/system/libsystem_notify.dylib",
    "/usr/lib/system/libsystem_sandbox.dylib",
    "/usr/lib/system/libsystem_secinit.dylib",
    "/usr/lib/system/libsystem_kernel.dylib",
    "/usr/lib/system/libsystem_platform.dylib",
    "/usr/lib/system/libsystem_pthread.dylib",
    "/usr/lib/system/libsystem_symptoms.dylib",
    "/usr/lib/system/libsystem_trace.dylib",
    "/usr/lib/system/libunwind.dylib",
    "/usr/lib/system/libxpc.dylib",
    "/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices",
    "/usr/lib/libDiagnosticMessagesClient.dylib",
    "/usr/lib/libenergytrace.dylib",
    "/usr/lib/libbsm.0.dylib",
    "/usr/lib/libz.1.dylib",
    "/usr/lib/system/libkxld.dylib",
    "/System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices",
    "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList",
    "/System/Library/Frameworks/Security.framework/Versions/A/Security",
    "/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration",
    "/usr/lib/libapple_nghttp2.dylib",
    "/usr/lib/libcompression.dylib",
    "/usr/lib/libnetwork.dylib",
    "/usr/lib/libsqlite3.dylib",
    "/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation",
    "/System/Library/Frameworks/Network.framework/Versions/A/Network",
    "/usr/lib/libCoreEntitlements.dylib",
    "/System/Library/PrivateFrameworks/MessageSecurity.framework/Versions/A/MessageSecurity",
    "/System/Library/PrivateFrameworks/ProtocolBuffer.framework/Versions/A/ProtocolBuffer",
    "/usr/lib/libMobileGestalt.dylib",
    "/System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression",
    "/usr/lib/libcoretls.dylib",
    "/usr/lib/libcoretls_cfhelpers.dylib",
    "/usr/lib/libpam.2.dylib",
    "/usr/lib/libxar.1.dylib",
    "/System/Library/PrivateFrameworks/CoreAutoLayout.framework/Versions/A/CoreAutoLayout",
    "/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration",
    "/usr/lib/libarchive.2.dylib",
    "/usr/lib/libxml2.2.dylib",
    "/usr/lib/liblangid.dylib",
    "/System/Library/Frameworks/Combine.framework/Versions/A/Combine",
    "/usr/lib/swift/libswiftCore.dylib",
    "/usr/lib/swift/libswiftCoreFoundation.dylib",
    "/usr/lib/swift/libswiftDarwin.dylib",
    "/usr/lib/swift/libswiftDispatch.dylib",
    "/usr/lib/swift/libswiftIOKit.dylib",
    "/usr/lib/swift/libswiftObjectiveC.dylib",
    "/usr/lib/swift/libswiftXPC.dylib",
    "/usr/lib/swift/libswift_Concurrency.dylib",
    "/usr/lib/swift/libswift_StringProcessing.dylib",
    "/usr/lib/swift/libswiftos.dylib",
    "/System/Library/PrivateFrameworks/AppleSystemInfo.framework/Versions/A/AppleSystemInfo",
    "/System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/Versions/A/IOMobileFramebuffer",
    "/System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface",
    "/usr/lib/libpcap.A.dylib",
    "/usr/lib/libdns_services.dylib",
    "/usr/lib/liblzma.5.dylib",
    "/usr/lib/libbz2.1.0.dylib",
    "/usr/lib/libiconv.2.dylib",
    "/usr/lib/libcharset.1.dylib",
    "/usr/lib/swift/libswift_RegexParser.dylib",
    "/usr/lib/libheimdal-asn1.dylib",
    "/usr/lib/libCheckFix.dylib",
    "/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC",
    "/System/Library/PrivateFrameworks/CoreNLP.framework/Versions/A/CoreNLP",
    "/System/Library/PrivateFrameworks/MetadataUtilities.framework/Versions/A/MetadataUtilities",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate",
    "/usr/lib/libmecab.dylib",
    "/usr/lib/libCRFSuite.dylib",
    "/usr/lib/libgermantok.dylib",
    "/usr/lib/libThaiTokenizer.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLinearAlgebra.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparseBLAS.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libQuadrature.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBNNS.dylib",
    "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparse.dylib",
    "/System/Library/PrivateFrameworks/MIL.framework/Versions/A/MIL",
    "/System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory",
    "/System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory",
    "/System/Library/PrivateFrameworks/APFS.framework/Versions/A/APFS",
    "/System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation",
    "/usr/lib/libutil.dylib",
    "/System/Library/PrivateFrameworks/InstalledContentLibrary.framework/Versions/A/InstalledContentLibrary",
    "/System/Library/PrivateFrameworks/CoreServicesStore.framework/Versions/A/CoreServicesStore",
    "/usr/lib/libapp_launch_measurement.dylib",
    "/System/Library/PrivateFrameworks/AppleMobileFileIntegrity.framework/Versions/A/AppleMobileFileIntegrity",
    "/usr/lib/libmis.dylib",
    "/System/Library/PrivateFrameworks/MobileSystemServices.framework/Versions/A/MobileSystemServices",
    "/System/Library/PrivateFrameworks/ConfigProfileHelper.framework/Versions/A/ConfigProfileHelper",
    "/System/Library/PrivateFrameworks/CoreAnalytics.framework/Versions/A/CoreAnalytics",
    "/System/Library/PrivateFrameworks/AppleSauce.framework/Versions/A/AppleSauce",
    "/System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling",
    "/usr/lib/libxslt.1.dylib",
    "/usr/lib/libcmph.dylib",
    "/System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/CoreEmoji",
    "/System/Library/PrivateFrameworks/LinguisticData.framework/Versions/A/LinguisticData",
    "/System/Library/PrivateFrameworks/Lexicon.framework/Versions/A/Lexicon",
    "/System/Library/PrivateFrameworks/BackgroundTaskManagement.framework/Versions/A/BackgroundTaskManagement",
    "/usr/lib/libTLE.dylib"
  ]
}

### next-swc installation

next-swc is installed correctly for aarch64-apple-darwin

### next-swc shared object dependencies

/Users/ojkwon/github/next.js-upstream/node_modules/@next/swc-darwin-arm64/next-swc.darwin-arm64.node:
	/Users/runner/work/next.js/next.js/target/aarch64-apple-darwin/release/deps/libnext_swc_napi.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1228.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60420.60.24)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1953.255.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

/Users/ojkwon/github/next.js-upstream/node_modules/@next/swc-darwin-arm64/next-swc.darwin-arm64.node [arm64]:
    -platform:
        platform     minOS      sdk
           macOS     12.0      13.1   
    -segments:
        load-offset   segment section        sect-size  seg-size perm
        0x00000000    __TEXT                             94304KB r.x
        0x00001680             __text           66042588
        0x03EFD15C             __stubs            3336
        0x03EFDE64             __init_offsets      112
        0x03EFDED4             __gcc_except_tab 5771520
        0x0447F000             __const          8830192
        0x04CEACF0             __cstring           128
        0x04CEAD70             __unwind_info    2417156
        0x04F38F78             __eh_frame       13496364
        0x05C18000    __DATA_CONST                        3040KB rw.
        0x05C18000             __got              2288
        0x05C188F0             __const          3101360
        0x05F10000    __DATA                               512KB rw.
        0x05F10000             __data           422352
        0x05F771D0             __thread_vars      1656
        0x05F77848             __thread_data       104
        0x05F778B0             __thread_bss       2776
        0x05F78388             __common          62704
        0x05F87880             __bss             18424
    -dependents:
        attributes     load path
                       /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
                       /System/Library/Frameworks/Security.framework/Versions/A/Security
                       /usr/lib/libSystem.B.dylib
                       /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
                       /usr/lib/libiconv.2.dylib
```


</details>
2023-08-03 17:03:41 +00:00
John Ide
57788b56f8
Adding docs about static exports not supporting dynamic segments (#52959)
Adding docs about how Dynamic Segments aren't supported with Static Exports.

- Related to https://github.com/vercel/next.js/issues/48022

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-02 18:27:31 +00: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
Jarrett Meyer
c7fa524ebd
docs: add clarity for deleting cookies (#52338)
Added additional methods for deleting a cookie




Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-08-02 17:02:51 +00:00
SubsequentlySneeds
c3f4e5d866
Minor grammar fix in "src Directory" page (#53481)
This change removes the sentence fragment starting with "Which" and merges it into the previous sentence.
2023-08-02 16:33:31 +00:00
Delba de Oliveira
eecd8dc146
Docs: update caching docs (#53478)
This PR:
- Makes minor content and formatting improvements
- Updates caching diagrams:
  - Adds missing static/dynamic diagram (fixes #53460) 
  - Tweaks designs to explain things better
  - Increases font sizes

Relies on: https://github.com/vercel/front/pull/24321
2023-08-02 12:11:22 +00:00
Steven
1b2e361e0d
chore(docs): add section about responsive images (#53463)
We got some feedback from that there is missing information when working with responsive images.

This PR adds a new section for Responsive Images along with some recipes how to achieve that.
2023-08-02 09:29:08 +00:00
leotrt
f51978beae
fix(doc): Broken link formatting in draft-mode doc (app router) (#53446)
### What?
Link to dynamic rendering is not appearing as such in the App router's draft-mode docs.

### Why?
The formatting is wrong, it misses a parenthesis

### How?
Added the missing parenthesis
2023-08-01 15:22:49 +00:00
Delba de Oliveira
dc3936b11a
Docs: Review Getting Started Section (#53377)
I've started reviewing the docs to identify areas we need to cover / improve. This PR contains minor improvements for the **getting started**, **installation**, and **project structure** pages.


New tasks added to linear: 
- Create [middleware.ts](https://linear.app/vercel/issue/DX-1834/create-middlewarets-api-reference-in-file-conventions) page
- Create [instrumentation.ts](https://linear.app/vercel/issue/DX-1833/create-instrumentationts-api-reference-in-file-conventions) page
2023-08-01 15:12:18 +00:00
Delba de Oliveira
b4d40f454e
Docs: Fix formatting issues in the caching docs (#53436) 2023-08-01 13:34:25 +00:00
Lee Robinson
19c4eec064
docs: fix broken diagram in caching docs (#53414)
Follow up from https://github.com/vercel/next.js/pull/52514.

We're still missing the static and dynamic diagram, it was missed in the PR to `front` to add the original diagrams. We'll need to get that in as well, could be here, or in a follow up.
2023-08-01 03:21:00 +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
Ozan Sevkin
97a0a3373f
docs: update active link code snippet for better equality check (#53327)
Update pathname and href matching check from startsWith() method to strict equality. startsWith() method causes all paths to match with root link "/"
2023-07-30 23:21:59 +00:00
JJ
d3b0c7bb42
[Docs] remove x-xss-protection-header (#53362)
The x-xss-protection header is a non-standardized http header with low browser-capability.
If it is likely to be supported in the future, it can be treated as experimental, but since it is not, it is preferable to remove it.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
https://caniuse.com/mdn-http_headers_x-xss-protection
2023-07-30 20:12:41 +00:00
Steven Tey
ed35e2a6ea
Added docs on async not-found.js server components (#51999)
While `not-found.js` components do not accept any props, you can still turn the `not-found.js` component into an async server component to fetch dynamic data:


```tsx filename="app/blog/not-found.tsx" switcher
import Link from 'next/link'
import { headers } from "next/headers";

export default async function NotFound() {
  const headersList = headers();
  const domain = headersList.get("host")
  const data = await getSiteData(domain)
  return (
    <div>
      <h2>Not Found: {data.name}</h2>
      <p>Could not find requested resource</p>
      <p>
        View <Link href="/blog">all posts</Link>
      </p>
    </div>
  )
}
```

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-07-29 07:33:28 +00:00
Dom Sip
b149fb7009
docs: Update Route Handlers AI example code snippet (#52127)
changing AI example model from `text-davinci-003` to `gpt-3.5-turbo`
which is in a `chat/route.ts` format.

The alternative but with "completition" style would be a bit longer code
like:

```
// app/api/completion/route.ts

import { Configuration, OpenAIApi } from 'openai-edge'
import { OpenAIStream, StreamingTextResponse } from 'ai'

export const runtime = 'edge'

const apiConfig = new Configuration({
  apiKey: process.env.OPENAI_API_KEY!,
})

const openai = new OpenAIApi(apiConfig)

function buildPrompt(prompt: string) {
  return prompt.split('\n').map((message) => ({
    role: 'user',
    content: message,
  }));
}

export async function POST(req: Request) {
  
  // Extract the `prompt` from the body of the request
  const { prompt } = await req.json();

  // Request the OpenAI API for the response based on the prompt
  const response = await openai.createChatCompletion({
    model: 'gpt-3.5-turbo',
    stream: true,
    messages: buildPrompt(prompt),
    max_tokens: 500,
    temperature: 0.7,
    top_p: 1,
    frequency_penalty: 1,
    presence_penalty: 1,
  })

  // Convert the response into a friendly text-stream
  const stream = OpenAIStream(response)

  // Respond with the stream
  return new StreamingTextResponse(stream)
}

```

<!-- 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: Lee Robinson <me@leerob.io>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-07-29 00:25:48 -07:00
Julien Bouquillon
71f08ef873
docs: fix typo (#53100)
just a typo in next/jest docs
2023-07-29 07:12:33 +00:00
Shunya Hayashi
dffafdecd3
Update nginx.conf example in documentation for improved flexibility and clarity (#53135)
## Description

This PR updates the provided example of nginx.conf in the documentation. The changes introduce more flexibility and clarity, making the example easier to understand and more suited for general use.

## What?

Changes include ↓

- Modifying the root directory to `/var/www/out`. This aligns more closely with typical server configurations and separates the public web content from other parts of the server.

- Updating the try_files directive for the `/` location block. The directive now attempts to serve `$uri`, `$uri.html`, and `$uri/` in that order. This setup caters to the common pattern in static websites of serving files derived directly from the URL and correctly handles URLs that omit the .html extension.

- The `/blog/` location block is retained as is, with the rewrite directive still relevant and not requiring changes.

## Why?

These modifications aim to improve the applicability of the example to a wider range of use cases and make it more comprehensible for new users.

## How?

The changes were made directly to the `nginx.conf` example provided in the docs, following the standard syntax and conventions of Nginx configuration files.


Please let me know if there are any questions, or if further modifications are needed !!

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-07-29 07:03:14 +00:00
Andrew Garvin
ce29de25e4
Fixed simple typo in documentation (#53317)
I think this is a typo, at the very least I found the sentence a little clunky.
2023-07-28 21:22:37 +00:00
Steven Tey
7f77f427d2
docs: Add next-international to examples list (#53303) 2023-07-28 21:04:22 +00:00
Zack Tanner
604681912b
ensure colocated unit tests run in CI & fix various failing tests (#53270)
Colocated unit tests (such as ones in `packages/next` and `packages/font`) weren't running in CI since `run-tests` marks the glob cwd as `<root>/tests`. This modifies the working directory to be the root so the new expanded test pattern will pick up files outside of `test/`.

Several of these tests were failing so there are updates in here to fix them. Specifically:

- Source Sans Pro font was renamed to Source Sans 3
- `fillCacheWithDataProperty` test was hitting the `bailOptimistic` code path
- `resolve-metadata` had an invalid assertion (`rel: icon` gets added as part of `IconsMetadata`)
- `resolve-opengraph` wasn't handling undefined images
- `server-patch-reducer` now use inline snapshots as one was failing since it now has a prefetchCache
2023-07-28 13:54:15 +00:00
Oyebadejo Michael
37bb09d36a
chore(docs): remove repeated closing bracket (#53268)
### Adding or Updating Examples

- The repeated closing bracket that comes just after "Server Actions" has been removed

### Fixing a bug

- fixes #53267
2023-07-27 19:35:34 +00:00
Balázs Orbán
7721b9ba64
docs: match image example with code (#53254)
Closes NEXT-1761
Fixes #52037
2023-07-27 12:27:50 +00:00
Florentin / 珞辰
f1bd1eda8e
[docs] add documentation for maxDuration segment option (#52326)
This PR documents the new `maxDuration` segment options that allows to opt into higher Vercel function timeouts.
2023-07-26 16:35:28 +00:00
Aryan Malik
ccc269a5ae
Update 01-installation.mdx (#53192)
Added switcher on `page/_document.tsx` example just for a consistency
2023-07-26 15:34:27 +00:00
Aryan Malik
4cb14b5110
Fix grammatical error in docs (#53197)
Changed 'created' to 'create' for improved grammar and clarity in the documentation.

Find it under `Custom App`
[https://nextjs.org/docs/pages/building-your-application/routing/custom-app](url)
2023-07-26 13:25:25 +00:00
Daniel
84197ece65
chore(docs): client-side data fetching loading state (#53164)
setLoading must be "true" at first and then set to "false". The documentation, as is, always has the value of setLoading set to "false".

The purpose of this code is to show "...loading" on the screen while the data is being fetched. In order for this to happen, setLoading must be initially set to "true" and then (after the data is successfully loaded) set to "false", since the line `if (isLoading) return <p>Loading...</p>` is asking if the content is still loading, and if it is, it'll return a message indicating it.

Because of this

### What?
setLoading should be set to "true" at first.

### Why?
Because the code then asks if the content is being loaded. The code (as is) always has setLoading set as "false" and it doesn't show the loading message when it's supposed to.

### How?
I changed the line to `const [isLoading, setLoading] = useState(true)`.




Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-07-25 16:49:40 +00:00
Steven
a0856eb596
chore: update warning message from yarn add sharp to npm i sharp (#53130)
Previously, this warning message assumed the user knew what `yarn` was and had it installed.

This PR changes the warning message to assume the user knows what `npm` is and has it installed, since `npm` ships with the official `node` installation.
2023-07-24 22:33:12 +00:00
Lee Robinson
436408272e
docs: fix codeblock for redirect (#53120)
Just needs a language 👍
2023-07-24 16:48:15 +00:00
vinay
c355fb1a38
(Docs) Remove FormData type on formData defined in .js file (#53014) 2023-07-24 15:47:35 +00:00
vinay
a18e2ec94b
(Docs) Add missing import for useRef() (#53015) 2023-07-23 21:41:10 +00:00
Paul Barry
85676da42c
chore(docs): Extend the options for custom server init (#52851)
## For Contributors

### Improving Documentation

While working with a custom server, I noticed that [the list of available options within the codebase](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/base-server.ts#L138-L180) was much larger than [the options listed within the docs](https://nextjs.org/docs/pages/building-your-application/configuring/custom-server). This PR extends the `next` import function options to include all of ~the allowed~ documented options from the codebase. 

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




Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-07-23 17:25:07 +00:00
Sungyun Hur
caeaa74dda
docs: fix typo in 08-parallel-routes.mdx (#53069)
### What?

Fix a typo in `08-parallel-routes.mdx` by adding a whitespace.

### Why?

<img width="783" alt="스크린샷 2023-07-23 오후 4 11 22" src="https://github.com/vercel/next.js/assets/8033896/0bb92fc5-5a6f-4461-895a-a956abf52a9d">


### How?
2023-07-23 17:01:38 +00:00
trigaten
e4871f6927
docs: remove unneeded good to know section during installation (#53078)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-07-23 09:49:51 -07:00
Vu Van Dung
a0ea5f2d79
Fix formData code snippet in route handler docs (#52532)
### Why?

The code snippet in the Route handler `formData` documentation

```ts
import { NextResponse } from 'next/server'
 
export async function POST(request: Request) {
  const formData = await request.formData()
  return NextResponse.json({ formData })
}
```

is slightly wrong, because `formData` is not a plain object and hence `return NextResponse.json({ formData })` doesn't actually work.

Since we are already in the topic of parsing `formData`, I also added a mention on `zod-form-data` which can be used to validate the form and parse it to non-string formats such as `number`.
2023-07-22 21:15:12 +00:00
vinay
94878fe719
(Docs) add missing import. (#52992)
`import { cookies } from 'next/headers'`
2023-07-22 05:05:38 +00:00
Steven
26a57af389
chore(docs): fix broken link (#53021)
This link is failing CI as seen here:

https://github.com/vercel/next.js/actions/runs/5623454975/job/15238167610


```
Error: The action could not create a Github comment because it is initiated from a forked repo. View the action logs for a list of broken links.
This PR introduces broken links to the docs:
┌─────────┬───────────────────────────────────────────────────────────────────────────────┬──────┬─────────────────────────────────────────────────────────────────────────────────────┐
│ (index) │                                     link                                      │ type │                                       docPath                                       │
├─────────┼───────────────────────────────────────────────────────────────────────────────┼──────┼─────────────────────────────────────────────────────────────────────────────────────┤
│    0    │ 'app/building-your-application/configuring/typescript#statically-typed-links' │      │ 'docs/02-app/01-building-your-application/01-routing/03-linking-and-navigating.mdx' │
└─────────┴───────────────────────────────────────────────────────────────────────────────┴──────┴─────────────────────────────────────────────────────────────────────────────────────┘
Error: This PR introduces broken links to the docs. The action could not create a Github check because it is initiated from a forked repo.
Error: Process completed with exit code 1.
```
2023-07-21 18:28:24 +00:00
Heidar-An
732219e9df
Update 02-dynamic-routes.mdx (#52975)
grammatical mistake

### What?
Small grammatical mistake on https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes
2023-07-21 17:08:52 +00:00
Shaun Ferris
3e34b9f2d2
"Clarify the 'Existing Projects' section of the TypeScript docs: (#52944)
> Add a sentence to the instructions for using typescript in an existing project instructing the user to copy the `paths` compiler option from the existing jsconfig file to the new tsconfig file.
> Not doing so causes absolute imports from project directories to break, and gives "Module Not Found" messages that the docs do not have a case for solving"
2023-07-21 15:09:28 +00:00
Cassidy Williams
7a0297c2d4
Change "publically" to "publicly" in the routing docs (#52966)
### What and why?

The word "publicly" should be spelled consistently across the documentation. It is spelled currently as "publically" in a few places.

### How?

Fixed the spelling!
2023-07-20 20:47:42 +00:00
Daryll J. Reillo
66f0983cb8
Update 06-lazy-loading.mdx: Incorrect filename in Example on "Importing Named Imports" (#52932)
The correct filename is seen on PagesOnly. But on AppOnly, the filename is not correct. It should be "hello" instead of "ClientComponent".

line to change:
from:
import('../components/ClientComponent').then((mod) => mod.Hello)

to:
import('../components/hello').then((mod) => mod.Hello)


line to change:
from:
import('../components/ClientComponent').then((mod) => mod.Hello)

to:
import('../components/hello').then((mod) => mod.Hello)
2023-07-20 12:57:18 +00:00
Soheil Nazari
20b115e827
wrong content for next.config.mjs for MDX Plugins (#52738) 2023-07-19 21:55:40 +00:00
Adam Hunter
2c1c8fa089
docs: fix example component in MDX documentation (#52753) 2023-07-19 14:25:31 -07:00
Steven
b12e6fef0c
chore(docs): fix typo in generate metadata docs (#52904)
- See current bug:
https://nextjs.org/docs/app/api-reference/functions/generate-metadata#generatemetadata-function
- Closes #52903
2023-07-19 14:21:18 -07:00
Antoine Bourin
08e87fb405
docs: add Typescript statically typed links mention in link doc (#52847) 2023-07-19 14:15:04 -07:00