How can redirect old link to new link after user edited

I want to build a blog by next and strapi like dev.to.But i have a problem with slug not have an idea to fix it.
With each article, I will create the path with the syntax: https://domain.com/username/slug (it like dev.to).
Example of dev.to: Easy user authentication with Next.js - DEV Community
But a problem , when the user change username, the path will be changed together, this time new url will be:

  • Old: https:// domain[.]com/username/slug
  • New: https:// domain[.]com/new_username/slug

So I want if users visit the old URL it be auto-redirect to the new url.
How can do it? how can a designer database in this case?
I no experience about this.I hope will be a little bit suggest from everybody. Thanks!