Search code examples
reactjsparse-platformcreate-react-appback4app

How to deploy React app (create-react-app) to Back4App?


I've created an React app with create-react-app and I want to deploy it to Back4App.

The problem is I want to deploy the build folder and not the public folder (which I understand is the default for Back4App / ParsePlatform).

So far, I haven't found any way to config deploy to use anything other than the public folder.

Any solution / workaround to this?


Solution

  • If you are using B4A CLI, one of the easiest ways to deploy a create-react-app is, firstly, changing the build script into your package.json as below snippet:

    ...
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build && cp -r build/* {{PATH-TO-YOUR-B4A-APP}}/public",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      },
    ...
    

    As you can see, you just need to move all content inside create-react-app build folder to the public folder of your cloud code. After that, move to your app path and run b4a deploy.

    Also, you could add a step to clear all public folder content before move the new stuff, but be careful with this step.

    Otherwise, you could access the Back4app Parse-Dashboard into the Cloud Code Functions and deploy all the build stuff in public folder using the browser interface.

    This is a live demo of a create-react-app deployed in Back4App.