How can I add authentication to my Nextra docs site made with nextra docs theme?

I have created a documentation site with nextra docs theme which consist of multipal mdx pages No i need to add authentication in my site?
below is my project structure: –
|
|_app
|
|pages
| _meta.json and all the mdx pages
|_public
|
|_middleware.js
|
|next.config,mjs
|
|
theme.config.jsx

I have tried with adding a middleware to my next.js