How to structure a project with multiple front-ends (i.e. React & React Native)
See original GitHub issueI’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:
- Created 5 years ago
- Reactions:7
- Comments:6 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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