#searchParams not updating

1 messages · Page 1 of 1 (latest)

ivory linden
#

I am using app router and I noticed that sometimes the query param in the browser and the one that my code reads from the browser are not the same. example in the image of network calls there is a call to my route with queryParam riskAssesmentId and the response from my server should respond with the same as a conversationId but the two are different.

here is an example of how I read the queryParam

export default async function Page({
searchParams,
}: {
searchParams: {[key: string]: string | undefined}
}) {
const token = cookies().get(USER_SESSION_KEY)?.value

if (!token) {
return notFound()
}

const ssn = searchParams['kennitala']!
const riskAssessmentId = searchParams['riskAssessment']!

plush pendantBOT
#

Hi @ivory linden. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the extracts provided, there isn't a direct mention or example related to the specific issue of searchParams not updating or being inconsistent with the browser's query parameters when using the app router in Next.js. The extracts focus on various issues and features related to Next.js, including handling of searchParams in production builds, shallow routing, and the behavior of useSearchParams() and useParams() hooks, but they do not address the specific scenario you're encountering.

However, the issue might be related to how Next.js handles routing and state updates, especially with dynamic routing and server-side rendering. If searchParams are not updating as expected, it could be due to the way Next.js or your application handles state synchronization between the client and server, or how the app router processes URL changes.

Since I can't provide a direct solution based on the extracts, I recommend reviewing the Next.js documentation on routing and dynamic routes, as well as the app router's handling of query parameters:

#

If these resources do not resolve your issue, consider searching for or asking a question on platforms like GitHub issues or Stack Overflow, where the community or the Next.js team might have encountered and solved similar issues.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: