Load balancing on a single domain

Hi all,

I want to know if it’s possible to host a website and a web-app on the same domain. I ask because I have a simple React/Next app that I want to host at example.com and once the user hits the “sign in” button, they go to another React app (that does not use Next.js), to the URL example.com/signin which is served by another React app. Once the user signs in (some sort of idToken is present in the localStorage), going to example.com should show you another view (dashboard view) from the second react app.

Ideally would like to keep the two apps separate (vs using a single react-only app) so the website can be decoupled from the app (for faster tweaking, can optimise it to load faster, etc)


It’s possible, but you’d probably have to build it locally. You’ll have to build the second React app, copy its built files to the static (or similar) folder of the NextJS app and then build this NextJS one. Then upload that generated folder to Netlify.

Other hacky way to do it would be to use a custom build plugin or something similar. So, considering you’ve a directory structure like:

-- NextJS app
  -- folder 1
  -- folder 2
  -- React app
    -- folder1
    -- folder2
  -- static

Your build command can look like cd "React app" && npm run build && cd .. && npm run build.

Then you can add a plugin on post build, to copy all the generated files from React app/dist/ to /dist/signin/ and it should work.