DEV Community

What's the matcher?

Gündoğdu Yakıcı on March 12, 2023

Hi there, I'm new in Next.js 13. I have a question for you. I will make a multi language web site and for this I use middleware.js. My folder stru...
Collapse
 
simplycomplexable profile image
Zack Sunderland

I'm not sure where you're finding that config object in documentation, but you're right you don't need it at all.

Collapse
 
gundogduyakici profile image
Gündoğdu Yakıcı
Collapse
 
simplycomplexable profile image
Zack Sunderland

I missed that you're using middleware. You don't actually need middleware to support different locales as long as you're not doing anything crazy with the url. What you've described is the default behavior.
If you do need to use middleware, the matcher is a regex that lets next know which routes the middleware should run on. For example you don't need to intercept compiled files so the regex you shared is excluding any paths that start with _next, where all the compiled files live.