question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to structure a project with multiple front-ends (i.e. React & React Native)

See original GitHub issue

I’m wanting to creating an Amplify project that contains a React front-end, as well as a React Native front-end. I’d like to share some code between the projects. I’d like to have each project use the AppSync API helpers that the CLI outputs (queries.js, mutations.js, etc.). And I’d like to share some of the codebase. How do I structure the project such that it will work with the Amplify CLI in a monorepo?

I was looking at using Lerna, which helps handle multiple “packages”, but I’m not sure how to structure the project. I was considering the following directory structure, but I don’t know if the Amplify CLI would support it:

lerna.json 
package.json 
-amplify/
  -.config/
  -#current-cloud-backend/
  -backend/
-packages/
  -my-react-native-project/
    package.json 
  -my-react-project/
    package.json
  -shared-code/
    package.json 
    aws-exports.js  

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ricardoribascommented, Mar 30, 2020

In the project i am working at the moment i have a similar problem. Our solution was to create an additional package as @yuth stated. Additionally, we add a postInstall script in package.json that will just add symlinks to all the frontends using amplify backend. In our case, it worked like a charm. 🎉 I hope this intel is useful.

2reactions
yuthcommented, Dec 6, 2018

The structure you have above should be fine. You could also separate backend as separate package where you would keep backend specific code and use it in both react and react-native project

lerna.json 
package.json 
-packages/
  -my-react-native-project/
    package.json 
  -my-react-project/
    package.json
  -backend-project/
    - amplify/
     - .config/
     - #current-cloud-backend/
     - backend/
    - package.json 
    - aws-exports.js  

Read more comments on GitHub >

github_iconTop Results From Across the Web

React / Project structure - Frontend Handbook - Infinum
When adding UI components, you should be able to group them in two root domains: core - primitives, low level components; shared -...
Read more >
Four ways to implement react.js and react-native - Medium
1. Using Monorepo with independent react applications i.e. web application and android/ios application. There will be a single repository i.e. ...
Read more >
React project structure for scale: decomposition, layers and ...
How to organize React projects in a way that is scalable, structured, modular, consistent and logical.
Read more >
How to Create a React App with a Node Backend
Step 1: Create your Node (Express) backend · Step 2: Create an API Endpoint · Step 3: Create your React frontend · Step...
Read more >
How to create a React Native app: Frontend developer's toolkit
CRNA creates an Expo project by default. You don't even have to install XCode or Android Studio. How? The platform does the native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found