Skip to content

How to mock useSearchParams() and pass Query Parameter [NextJS routing]? #28255

Discussion options

You must be logged in to vote

You need to wrap your component with SearchParamsContext, as you did with AppRouterContext:
Something like that:

const params = new URLSearchParams({your search parameters as a string});
...
<SearchParamsContext.Provider value={params}>
    {component}
</SearchParamsContext.Provider>
...

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@alamenai
Comment options

@alamenai
Comment options

Comment options

You must be logged in to vote
1 reply
@alamenai
Comment options

Answer selected by alamenai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants