How to write a file in netlify on build

Hi Team,

So in contentful cms we are maintaining the redirect url information. I want that information to be written in _redirect file. Is it possible in build. How to achieve it. I’m using NextJS, Graphql for fetching records and hosting in netlify.

Any examples, links are appreciated.

Use build plugins: Create Build Plugins | Netlify Docs and add redirects to netlifyConfig.