How implement refresh token flow in NextJS SDK

Hi, I am working in a APP with nextjs and auth0, I want to know about how the refresh tokens works, the official docs are not clear and dont bring code examples.

I am following the basic instructions that is enable refresh tokens in the auth dashboard and add the offline_access in the scope of login, but I dont know what more to do.

Currently the middleware looks like this, but the validation is not working correctly because after 24 hours (1 day) the access token expires.

Can anyone explain what more config or logic I need to add or have a repository of code I can refer to?