Can not read searchParams props in Next.js 13.4

PLEASE help us help you by writing a good post!

Hello,
I don’t know why my page does not read the searchParams prop (link) from Next.js 13 in production. In dev it works as expected.

Site: https://inmogolfbonalba.netlify.app/en/propiedades?operacion=operacion-obra-nueva
Repo: inmosanity/page.tsx at a973eceeb57a591582d6ad1e99a5823726369871 · thewinger/inmosanity · GitHub

11:15:46 PM: build-image version: 4b067841aaa59ef71931d3505b98c2bc3e63f36f (focal)
11:15:46 PM: buildbot version: 4b067841aaa59ef71931d3505b98c2bc3e63f36f
11:15:47 PM: Fetching cached dependencies
11:15:47 PM: Starting to download cache of 1.4GB
11:16:00 PM: Finished downloading cache in 13.426s
11:16:00 PM: Starting to extract cache
11:16:07 PM: Finished extracting cache in 6.899s
11:16:07 PM: Finished fetching cache in 20.47s
11:16:07 PM: Starting to prepare the repo for build
11:16:07 PM: Preparing Git Reference refs/heads/netlify
11:16:08 PM: Parsing package.json dependencies
11:16:09 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'next build' versus 'yarn build' in the Netlify UI
11:16:09 PM: Starting to install dependencies
11:16:09 PM: Python version set to 3.8
11:16:09 PM: Attempting Ruby version 2.7.2, read from environment
11:16:10 PM: Using Ruby version 2.7.2
11:16:10 PM: Started restoring cached go cache
11:16:10 PM: Finished restoring cached go cache
11:16:10 PM: go version go1.19.9 linux/amd64
11:16:11 PM: Using PHP version 8.0
11:16:12 PM: Started restoring cached Node.js version
11:16:12 PM: Finished restoring cached Node.js version
11:16:12 PM: v16.20.0 is already installed.
11:16:13 PM: Now using node v16.20.0 (npm v8.19.4)
11:16:13 PM: Enabling Node.js Corepack
11:16:13 PM: Started restoring cached build plugins
11:16:13 PM: Finished restoring cached build plugins
11:16:13 PM: Started restoring cached corepack dependencies
11:16:13 PM: Finished restoring cached corepack dependencies
11:16:13 PM: Started restoring cached yarn cache
11:16:18 PM: Finished restoring cached yarn cache
11:16:18 PM: No yarn workspaces detected
11:16:18 PM: Started restoring cached node modules
11:16:18 PM: Finished restoring cached node modules
11:16:18 PM: Installing npm packages using Yarn version 1.22.19
11:16:18 PM: yarn install v1.22.19
11:16:18 PM: [1/4] Resolving packages...
11:16:19 PM: success Already up-to-date.
11:16:19 PM: Done in 0.35s.
11:16:19 PM: npm packages installed using Yarn
11:16:19 PM: Install dependencies script success
11:16:19 PM: Starting build script
11:16:20 PM: Detected 1 framework(s)
11:16:20 PM: "next" at version "13.4.3"
11:16:20 PM: Section completed: initializing
11:16:21 PM: ​
11:16:21 PM: Netlify Build                                                 
11:16:21 PM: ────────────────────────────────────────────────────────────────
11:16:21 PM: ​
11:16:21 PM: ❯ Version
11:16:21 PM:   @netlify/build 29.11.5
11:16:21 PM: ​
11:16:21 PM: ❯ Flags
11:16:21 PM:   baseRelDir: true
11:16:21 PM:   buildId: 6467e6fe0371f600087d3219
11:16:21 PM:   deployId: 6467e6fe0371f600087d321b
11:16:21 PM: ​
11:16:21 PM: ❯ Current directory
11:16:21 PM:   /opt/build/repo
11:16:21 PM: ​
11:16:21 PM: ❯ Config file
11:16:21 PM:   /opt/build/repo/netlify.toml
11:16:21 PM: ​
11:16:21 PM: ❯ Context
11:16:21 PM:   production
11:16:21 PM: ​
11:16:21 PM: ❯ Using Next.js Runtime - v4.37.1
11:16:22 PM: ​
11:16:22 PM: @netlify/plugin-nextjs (onPreBuild event)                     
11:16:22 PM: ────────────────────────────────────────────────────────────────
11:16:22 PM: ​
11:16:22 PM: Next.js cache restored.
11:16:22 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
11:16:22 PM: ​
11:16:22 PM: (@netlify/plugin-nextjs onPreBuild completed in 191ms)
11:16:22 PM: ​
11:16:22 PM: build.command from netlify.toml                               
11:16:22 PM: ────────────────────────────────────────────────────────────────
11:16:22 PM: ​
11:16:22 PM: $ next build
11:16:23 PM: - info Creating an optimized production build...
11:16:36 PM: - info Compiled successfully
11:16:36 PM: - info Linting and checking validity of types...
11:16:39 PM: - info Collecting page data...
11:16:41 PM: - info Generating static pages (0/69)
11:16:41 PM: - warn Entire page /[lang]/[slug] deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /[lang]/[slug]
11:16:41 PM: - warn Entire page /[lang]/[slug] deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /[lang]/[slug]
11:16:45 PM: - info Generating static pages (17/69)
11:16:52 PM: - info Generating static pages (34/69)
11:16:59 PM: - info Generating static pages (51/69)
11:17:07 PM: - info Generating static pages (69/69)
11:17:08 PM: - info Finalizing page optimization...
11:17:08 PM: Route (app)                                Size     First Load JS
11:17:08 PM: ┌ ● /[lang]                                0 B                0 B
11:17:08 PM: ├   ├ /es
11:17:08 PM: ├   └ /en
11:17:08 PM: ├ ● /[lang]/[slug]                         0 B                0 B
11:17:08 PM: ├   ├ /es/aviso-legal
11:17:08 PM: ├   └ /en/aviso-legal
11:17:08 PM: ├ ● /[lang]/propiedad/[slug]               0 B                0 B
11:17:08 PM: ├   ├ /es/propiedad/a296
11:17:08 PM: ├   ├ /es/propiedad/v021
11:17:08 PM: ├   ├ /es/propiedad/v115
11:17:08 PM: ├   └ [+59 more paths]
11:17:08 PM: ├ λ /[lang]/propiedades                    0 B                0 B
11:17:08 PM: ├ ○ /favicon.ico                           0 B                0 B
11:17:08 PM: └ λ /studio/[[...index]]                   683 kB          766 kB
11:17:08 PM: + First Load JS shared by all              77.6 kB
11:17:08 PM:   ├ chunks/139-126e8c3a93459eca.js         24.8 kB
11:17:08 PM:   ├ chunks/2443530c-26bd1c2cb2f545c8.js    50.5 kB
11:17:08 PM:   ├ chunks/main-app-ce2a9403e91a0ee1.js    224 B
11:17:08 PM:   └ chunks/webpack-1e1a7a27d9f48035.js     2.05 kB
11:17:08 PM: Route (pages)                              Size     First Load JS
11:17:08 PM: ─ ○ /404                                   180 B          84.4 kB
11:17:08 PM: + First Load JS shared by all              84.2 kB
11:17:08 PM:   ├ chunks/main-2259c120b86064d8.js        81.9 kB
11:17:08 PM:   ├ chunks/pages/_app-dec1a83570915fb0.js  195 B
11:17:08 PM:   └ chunks/webpack-1e1a7a27d9f48035.js     2.05 kB
11:17:08 PM: λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
11:17:08 PM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
11:17:08 PM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
11:17:08 PM: ​
11:17:08 PM: (build.command completed in 45.3s)
11:17:08 PM: ​
11:17:08 PM: @netlify/plugin-nextjs (onBuild event)                        
11:17:08 PM: ────────────────────────────────────────────────────────────────
11:17:08 PM: ​
11:17:08 PM: Patching /opt/build/repo/node_modules/next/dist/server/base-server.js
11:17:08 PM: Done
11:17:08 PM: Patching /opt/build/repo/node_modules/next/dist/server/next-server.js
11:17:08 PM: Done
11:17:08 PM: Moving static page files to serve from CDN...
11:17:08 PM: Moved 132 files
11:17:08 PM: Using Netlify Edge Functions for image format detection. Set env var "NEXT_DISABLE_EDGE_IMAGES=true" to disable.
11:17:08 PM: ✨ Deploying middleware and functions to Netlify Edge Functions ✨
11:17:08 PM: This feature is in beta. Please share your feedback here: https://ntl.fyi/next-netlify-edge
11:17:08 PM: Netlify configuration property "redirects" value changed to [
11:17:08 PM:   {
11:17:08 PM:     from: '/',
11:17:08 PM:     query: {},
11:17:08 PM:     to: '/en',
11:17:08 PM:     status: 301,
11:17:08 PM:     force: false,
11:17:08 PM:     conditions: { Language: [Array] },
11:17:08 PM:     headers: {}
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/',
11:17:08 PM:     query: {},
11:17:08 PM:     to: '/es',
11:17:08 PM:     status: 301,
11:17:08 PM:     force: false,
11:17:08 PM:     conditions: { Language: [Array] },
11:17:08 PM:     headers: {}
11:17:08 PM:   },
11:17:08 PM:   { from: '/_next/static/*', to: '/static/:splat', status: 200 },
11:17:08 PM:   {
11:17:08 PM:     from: '/_next/image*',
11:17:08 PM:     query: { url: ':url', w: ':width', q: ':quality' },
11:17:08 PM:     to: '/_ipx/w_:width,q_:quality/:url',
11:17:08 PM:     status: 301
11:17:08 PM:   },
11:17:08 PM:   { from: '/_ipx/*', to: '/.netlify/builders/_ipx', status: 200 },
11:17:08 PM:   { from: '/cache/*', to: '/404.html', status: 404, force: true },
11:17:08 PM:   { from: '/server/*', to: '/404.html', status: 404, force: true },
11:17:08 PM:   { from: '/serverless/*', to: '/404.html', status: 404, force: true },
11:17:08 PM:   { from: '/trace', to: '/404.html', status: 404, force: true },
11:17:08 PM:   { from: '/traces', to: '/404.html', status: 404, force: true },
11:17:08 PM:   {
11:17:08 PM:     from: '/routes-manifest.json',
11:17:08 PM:     to: '/404.html',
11:17:08 PM:     status: 404,
11:17:08 PM:     force: true
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/build-manifest.json',
11:17:08 PM:     to: '/404.html',
11:17:08 PM:     status: 404,
11:17:08 PM:     force: true
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/prerender-manifest.json',
11:17:08 PM:     to: '/404.html',
11:17:08 PM:     status: 404,
11:17:08 PM:     force: true
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/react-loadable-manifest.json',
11:17:08 PM:     to: '/404.html',
11:17:08 PM:     status: 404,
11:17:08 PM:     force: true
11:17:08 PM:   },
11:17:08 PM:   { from: '/BUILD_ID', to: '/404.html', status: 404, force: true },
11:17:08 PM:   {
11:17:08 PM:     from: '/api/*',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/Inter-Bold.woff',
11:17:08 PM:     to: '/Inter-Bold.woff',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/Logo_Inmogolf.png',
11:17:08 PM:     to: '/Logo_Inmogolf.png',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/Logo_Inmogolf.psd',
11:17:08 PM:     to: '/Logo_Inmogolf.psd',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/background.png',
11:17:08 PM:     to: '/background.png',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/break_iterator.wasm',
11:17:08 PM:     to: '/break_iterator.wasm',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/es.svg',
11:17:08 PM:     to: '/es.svg',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/favicon.ico',
11:17:08 PM:     to: '/favicon.ico',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/footer_border.svg',
11:17:08 PM:     to: '/footer_border.svg',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/hero-golf.jpg',
11:17:08 PM:     to: '/hero-golf.jpg',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/hero-golfball.jpeg',
11:17:08 PM:     to: '/hero-golfball.jpeg',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/uk.svg',
11:17:08 PM:     to: '/uk.svg',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/static/media/Logo_Inmogolf.64178fb3.png',
11:17:08 PM:     to: '/static/media/Logo_Inmogolf.64178fb3.png',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/static/media/es.b645a4a2.svg',
11:17:08 PM:     to: '/static/media/es.b645a4a2.svg',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/static/media/uk.e38acaa1.svg',
11:17:08 PM:     to: '/static/media/uk.e38acaa1.svg',
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     status: 200
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/*',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     conditions: { Cookie: [Array] },
11:17:08 PM:     force: true
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/_next/data/oFBEil6d_LEdz5rQojbf7/studio.json',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/_next/data/oFBEil6d_LEdz5rQojbf7/studio/*',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/studio',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/studio/*',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/:lang.rsc',
11:17:08 PM:     to: '/.netlify/builders/___netlify-odb-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/:lang',
11:17:08 PM:     to: '/.netlify/builders/___netlify-odb-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/:lang/propiedad/:slug.rsc',
11:17:08 PM:     to: '/.netlify/builders/___netlify-odb-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/:lang/propiedad/:slug',
11:17:08 PM:     to: '/.netlify/builders/___netlify-odb-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/_next/data/oFBEil6d_LEdz5rQojbf7/:lang/propiedades.json',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/:lang/propiedades',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/:lang/:slug.rsc',
11:17:08 PM:     to: '/.netlify/builders/___netlify-odb-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/:lang/:slug',
11:17:08 PM:     to: '/.netlify/builders/___netlify-odb-handler',
11:17:08 PM:     status: 200,
11:17:08 PM:     force: false
11:17:08 PM:   },
11:17:08 PM:   {
11:17:08 PM:     from: '/*',
11:17:08 PM:     to: '/.netlify/functions/___netlify-handler',
11:17:08 PM:     status: 200
11:17:08 PM:   }
11:17:08 PM: ].
11:17:08 PM: ​
11:17:08 PM: (@netlify/plugin-nextjs onBuild completed in 92ms)
11:17:08 PM: ​
11:17:08 PM: Functions bundling                                            
11:17:08 PM: ────────────────────────────────────────────────────────────────
11:17:08 PM: ​
11:17:08 PM: Packaging Functions from .netlify/functions-internal directory:
11:17:08 PM:  - ___netlify-handler/___netlify-handler.js
11:17:08 PM:  - ___netlify-odb-handler/___netlify-odb-handler.js
11:17:08 PM:  - _ipx/_ipx.js
11:17:08 PM: ​
11:17:38 PM: ​
11:17:38 PM: (Functions bundling completed in 30.1s)
11:17:38 PM: ​
11:17:38 PM: Edge Functions bundling                                       
11:17:38 PM: ────────────────────────────────────────────────────────────────
11:17:38 PM: ​
11:17:38 PM: Packaging Edge Functions from .netlify/edge-functions directory:
11:17:38 PM:  - ipx
11:17:38 PM:  - rsc-data
11:17:39 PM: ​
11:17:39 PM: (Edge Functions bundling completed in 854ms)
11:17:39 PM: ​
11:17:39 PM: @netlify/plugin-nextjs (onPostBuild event)                    
11:17:39 PM: ────────────────────────────────────────────────────────────────
11:17:39 PM: ​
11:17:39 PM: Next.js cache saved.
11:17:39 PM: 🧪 Thank you for testing "appDir" support on Netlify. For known issues and to give feedback, visit https://ntl.fyi/next-13-feedback
11:17:39 PM: ​
11:17:39 PM: (@netlify/plugin-nextjs onPostBuild completed in 361ms)
11:17:39 PM: ​
11:17:39 PM: Deploy site                                                   
11:17:39 PM: ────────────────────────────────────────────────────────────────
11:17:39 PM: ​
11:17:39 PM: Starting to deploy site from '.next'
11:17:40 PM: Calculating files to upload
11:17:40 PM: 159 new files to upload
11:17:40 PM: 3 new functions to upload
11:17:49 PM: Section completed: deploying
11:17:49 PM: Site deploy was successfully initiated
11:17:49 PM: ​
11:17:49 PM: (Deploy site completed in 9.4s)
11:17:49 PM: Starting post processing
11:17:49 PM: ​
11:17:49 PM: Netlify Build Complete                                        
11:17:49 PM: ────────────────────────────────────────────────────────────────
11:17:49 PM: ​
11:17:49 PM: Skipping HTML post processing
11:17:49 PM: (Netlify Build completed in 1m 27.8s)
11:17:49 PM: Post processing - header rules
11:17:49 PM: Post processing - redirect rules
11:17:49 PM: Caching artifacts
11:17:49 PM: Started saving node modules
11:17:49 PM: Finished saving node modules
11:17:49 PM: Post processing done
11:17:49 PM: Started saving build plugins
11:17:49 PM: Finished saving build plugins
11:17:49 PM: Started saving corepack cache
11:17:50 PM: Section completed: postprocessing
11:17:49 PM: Finished saving corepack cache
11:17:49 PM: Started saving yarn cache
11:17:50 PM: Site is live ✨
11:17:53 PM: Finished saving yarn cache
11:17:53 PM: Started saving pip cache
11:17:53 PM: Finished saving pip cache
11:17:53 PM: Started saving emacs cask dependencies
11:17:53 PM: Finished saving emacs cask dependencies
11:17:53 PM: Started saving maven dependencies
11:17:53 PM: Finished saving maven dependencies
11:17:53 PM: Started saving boot dependencies
11:17:53 PM: Finished saving boot dependencies
11:17:53 PM: Started saving rust rustup cache
11:17:53 PM: Finished saving rust rustup cache
11:17:53 PM: Started saving go dependencies
11:17:53 PM: Finished saving go dependencies
11:17:53 PM: Build script success
11:17:53 PM: Section completed: building
11:17:59 PM: Uploading Cache of size 1.4GB
11:18:08 PM: Section completed: cleanup
11:18:08 PM: Finished processing build request in 2m21.927s

This has nothing to do with search params, rather it’s this issue: Server.edge not defined Error on nextJS SSR functions cause site to return 500 Errors

Please follow that thread.

Tried that solution and added the env variable they suggest but then I get the error
‘Invalid AWS Lambda parameters used in this request.’

Will keep and eye on the topic as I see the are working on it.

I followed the thread. Added the prebuild script and everything works, even sanity studio… but searchParams are still not read.

This link should have only 2 results but it’s returning all of them.

And also, using netlify dev, the middleware.ts doesn’t even work properly.

EDIT: If you enter directly to the link or reload the page it seems to work, but if you get to it by clicking “Search” it doesn’t. (Works as expected in vercel)

EDIT@: Middleware issues in local solved by removing the matcher. (Next.js on Netlify Edge Functions Beta discussion · netlify/next-runtime · Discussion #1319 · GitHub)

I had to change the search buttons that did a router.push (soft-navigation) to anchors so it does a hard-navigation and then shows the correct results, with the router.push it wasn’t reading the prop searchParams of the page.