Next.js Discord

Discord Forum

How do I get a query param from a string in next.js?

Answered
noli posted this in #help-forum
Open in Discord
Avatar
Using an example string, I typed:
const searchParams = new URLSearchParams("https://randomlink.com/collection?i=hjd29JND");
                        
console.log(searchParams.get('i'));


but it keeps printing Null and I can't find anything to help.

2 Replies

Avatar
my code right now
Image
Answer