Running nextjs build and api

I’m trying to run a build for both nextjs and my api server. Because the nextjs build relies on ‘next-on-netlify’ and my api relies on a lambda functiont, if I try to put them both in one command it will either build nextjs and then not build the api or if I try to put them both it one command with npm-run-all it then doesn’t build correctly as the postBuild next-on-netlify doesn’t build the files.

How can I run both my nextjs build and api build in the same command?

“scripts”: {
“dev”: “next dev”
“build”: “next build”,
“start”: “next build”,
“postbuild”: “next-on-netlify”,
“buildApi”: “./node_modules/.bin/netlify-lambda build src”

I have changed the scripts slight and I can see first of all it builds the api and outputs it to out_publish however the file api.js is being overwritten by the next-on-netlify build when it outputs to out_publish, is there anyway to prevent this?

     "build": "run-s buildApi start ",
     "start": "next build",  
     "postbuild": "next-on-netlify",
     "buildApi": "./node_modules/.bin/netlify-lambda build src"

hey @relaxen159 i think you might also be the person who opened an issue in the next-on-netlify repo? regardless, finn’s reply should be exactly what you need! :slight_smile: