Recommended workflow for React app with GitHub deployment

I’ve got my Realm ‘backend’ repo set up with GitHub deployment so pushing to master deploys to Realm. Awesome! Further, I’m thinking of using Realm static hosting to host the app (in the past I’ve used Netlify, which I love, but why not consolidate?)

My question is this. Normally I’d use a separate repo for my client app. Realm static hosting lives inside the ‘backend’ repo (/hosting/files/). It feels unwieldy to me to have the entire React project inside that already-nested directory.

So I could use a separate client repo and make a deployment script that builds and copies the react app into the hosting dir., but that ALSO feels unwieldy to me.

Am I just being overly picky? What would you do? Are there pros and cons to either approach? Or something else?

Personally, I’d probably keep everything in the same repo.

If you do want to keep your client app in a separate repo then that can work too. Note that you can have many Realm apps and so you could create a new one that you only use for the static hosting. You can then sync that app with the repo that contains your client app. Of course, you’d still need to respect the directory structure.

Oh, that’s interesting…
W.r.t. keeping everything in the same repo, are there any caveats/cons? I’m going to use create-react-app for this project, but it’s unclear to me how to set that up in this case. Would you store the source in the root, and then modify the build script to build to /hosting/files? What else would have to be modified?

Possibly, would just need to check that the import into the Realm app didn’t object to the source files being there (if it does then the source code would need to be stored in a different repo and then I’d look into using GitHub actions to copy the build files over).

Good news! I created a /client directory and ran create-react-app there, then created a .env file in /client that specifies the correct build path (../hosting/files). Ran a test build, committed and pushed and everything works perfectly! One tiny detail that you might want to add to the docs is that /hosting/files can’t be empty or deployment will fail.

1 Like