Next.js

Next.js

How do you handle redirects in Next.js?

Redirects can be set up in next.config.js using the redirects property.

module.exports = { async redirects() { return [ { source: '/old-path', destination: '/new-path', permanent: true } ]; } };

This creates a permanent redirect from /old-path to /new-path.

To post a comment or share your answer, please log in first

No comments yet. Be the first to share your thoughts!

1 / 18