I am trying to get the params in a url redirected from the Spotify api, ex: http//link.com/?code=examplecode How can I get the value of code before it renders so I can redirect it and pass the code value to another page?
4 Answers
For someone trying to use Routers using dynamic routing in NextJs
import { useRouter } from 'next/router';
const {query} =useRouter();
const id=query.[your file name];
For example:
If your structure has a route Profile and under that you have [username.js].So your code will be like this:
const id=query.username;