Skip to content

Deploy an app using react native cli (not expo) and amplify gen 2

0

Unfortunately I am not able to pass build using react native. I am building a new react native app from scratch (let say the example of the todo list app in the duc) I try to deploy the app and it is always bring an error I believe the main problem is with hot to configure the amplify.yml can you help me edit this for make it work, I am also suggesting you to upload a git of react native app that work with Gen 2: We are a team of programers who wanted to work with amplify gen 2 and react native and we are so desperate that we think to use amplify gen 1 or event to use other options...

amplify.yml just help me fill using npm: version: 1 backend: phases: build: commands: - ''

frontend: phases: build: commands: - '' artifacts: baseDirectory: files: - '' cache: paths: - ''

asked a year ago501 views
1 Answer
-1

I understand your frustration with deploying a React Native app using Amplify Gen 2. Unfortunately, as of now, Amplify Gen 2 does not have official support for React Native CLI projects. It's primarily designed for web applications and Expo-based React Native projects.

For a React Native CLI project, you would need to use Amplify Gen 1, which has better support for React Native CLI projects. If you're set on using Amplify Gen 2, you might need to consider switching to an Expo-based project or a web-based React application.

However, if you want to try configuring the amplify.yml file for a React Native CLI project with Amplify Gen 2, here's a potential configuration:

version: 1
backend:
  phases:
    build:
      commands:
        - amplify push --yes
frontend:
  phases:
    preBuild:
      commands:
        - npm install
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: android/app/build/outputs/apk/release
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

This configuration assumes you're building an Android app. For iOS, you'd need to adjust the baseDirectory under artifacts.

Please note that this configuration might not work perfectly due to the lack of official support for React Native CLI in Amplify Gen 2. You might encounter issues during the build process.

Given the challenges you're facing, I would recommend considering these options:

  1. Use Amplify Gen 1, which has better support for React Native CLI projects.
  2. Convert your project to use Expo, which is better supported by Amplify Gen 2.
  3. Consider using Amplify Gen 2 for the backend services only, and handle the React Native app deployment separately.

If you decide to stick with Amplify Gen 1, you'll find more comprehensive documentation and support for React Native CLI projects. The setup process would involve initializing your Amplify project with amplify init and then adding the necessary features like authentication, API, or storage using the respective Amplify CLI commands.

I apologize that I can't provide a perfect solution for using React Native CLI with Amplify Gen 2. The technology is still evolving, and hopefully, better support for React Native CLI projects will be available in future updates of Amplify Gen 2.
Sources
Deploying a web application using AWS Amplify Gen 2 with GitLab as the Repository on AWS | Front-End Web & Mobile
Tutorial - Add authentication - React Native - AWS Amplify Docs

answered a year ago
  • If I understand well I can use Amplify Gen 2 with react native cli only I cannot deploy the app using Amplify but I can use the services? In addition if I want to use Amplify Gen 2 for the backend services only and the front end to be in react native I can also access the backend without any problem although in the package.json of the front there wont be any amplify? In addition I deploy only the front to the appstore and the backend deploy to the amplify?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.