In the context of NextJS middleware, I have successfully obtained the nextUrl
object from the request, which includes details like the pathname. However, I am now wondering how to extract query string parameters directly within the middleware. Although I could manually parse the string returned by href, I would like to know if these parameters are available in a separate object.
For example:
export const middleware = (request) => {
const { nextUrl: { query } } = request;
...
};
Assuming query
contains:
{
param1: 'foo',
param2: 'bar',
etc.
}