Quickstarters
CRUD Samples
How to Build a CRUD App with React Native?
30 min
overview in this tutorial, you'll learn how to craft a react native application that performs essential crud (create, read, update, delete) operations using back4app as your cloud backend this guide will walk you through creating a project in back4app, setting up a flexible data model, and integrating your react native app with the backend using restful apis initially, you'll establish a back4app project titled basic crud app reactnative to serve as your backend you will then design your data schema by manually defining classes and fields in the back4app dashboard or using the integrated ai agent for assistance after configuring your backend, you will use the back4app admin app, which offers a user friendly drag and drop interface for managing your data, making it easier to perform crud operations by the conclusion of this guide, you will have a fully functional react native application that can create, read, update, and delete records while also supporting secure user authentication and data handling main benefits build a mobile app learn to develop a react native crud application with a robust backend backend integration understand how to design and integrate a scalable data model using back4app effortless data management use back4app’s admin app to quickly manage your application's data secure operations implement secure user authentication and data privacy measures prerequisites before you begin, make sure you have an active back4app account with a new project set up need help? refer to getting started with back4app https //www back4app com/docs/get started/new parse app a react native development environment install tools such as node js, npm (or yarn), and the react native cli expo can also be used for rapid prototyping familiarity with react, javascript, and rest apis consult the react native documentation https //reactnative dev/docs/getting started if you need a refresher step 1 – setting up your back4app project creating your back4app project log in to your back4app account click the “new app” button on your dashboard name your project basic crud app reactnative and follow the prompts to complete the setup create new project after your project is created, it will appear on your dashboard, laying the foundation for your backend configuration step 2 – crafting your data model structuring your data for this crud app, you'll define a couple of collections within your back4app project below are examples of the key collections and fields necessary to support the core crud functionalities 1\ collection items this collection stores the details for each item field type description id objectid auto generated unique identifier title string name or title of the item description string a brief explanation of the item createdat date timestamp for when the item was added updatedat date timestamp for the most recent update 2\ collection users this collection manages user credentials and authentication information field type description id objectid automatically generated unique identifier username string unique identifier for the user email string user’s email address (must be unique) passwordhash string hashed password for secure login createdat date time when the account was created updatedat date time when the account details were last updated you can define these collections and their fields via the back4app dashboard create new class you can add new fields by selecting the data type, entering a field name, setting a default value, and marking whether it’s required create column using the back4app ai agent for schema generation the integrated ai agent in back4app can automatically construct your data schema from a simple description this tool helps streamline your project setup and ensures your data model supports the necessary crud operations how to use the ai agent open the ai agent go to your project settings on the back4app dashboard and select the ai agent describe your schema input a detailed description of the collections and fields you need review and confirm the ai agent will suggest a schema; review it and confirm to apply the configuration sample prompt create the following collections in my back4app project 1\) collection items \ fields \ id objectid (auto generated) \ title string \ description string \ createdat date (auto generated) \ updatedat date (auto updated) 2\) collection users \ fields \ id objectid (auto generated) \ username string (unique) \ email string (unique) \ passwordhash string \ createdat date (auto generated) \ updatedat date (auto updated) this method saves you time and ensures consistency in your data model step 3 – using the admin app for data management overview of the admin app the back4app admin app provides a no code interface that simplifies backend data management its drag and drop functionality allows you to perform crud operations—adding, viewing, updating, and deleting records—without writing complex queries enabling the admin app go to the “more” menu in your back4app dashboard click on “admin app” and then select “enable admin app ” set up admin credentials create your initial admin account, which also sets up system roles like b4aadminuser enable admin app once activated, log into the admin app to manage your application data admin app dashboard managing crud operations via the admin app within the admin app, you can insert new records use the “add record” function in any collection (e g , items) to introduce new data examine/modify records select a record to review details or update its fields delete records remove entries that are no longer necessary this streamlined tool improves your workflow by making data management straightforward step 4 – integrating your react native app with back4app after setting up your backend, it’s time to connect your react native application to back4app using rest apis for integration although there is a parse sdk available for javascript, in a react native environment you may opt to use standard rest api calls for flexibility below is an example of how to perform crud operations using the javascript fetch api example fetching items async function fetchitems() { try { const response = await fetch('https //parseapi back4app com/classes/items', { method 'get', headers { 'x parse application id' 'your application id', 'x parse rest api key' 'your rest api key' } }); const data = await response json(); console log('fetched items ', data results); } catch (error) { console error('error fetching items ', error); } } export default fetchitems; example creating a new item async function createitem(title, description) { try { const response = await fetch('https //parseapi back4app com/classes/items', { method 'post', headers { 'x parse application id' 'your application id', 'x parse rest api key' 'your rest api key', 'content type' 'application/json' }, body json stringify({ title, description }) }); const data = await response json(); console log('item created ', data); } catch (error) { console error('error creating item ', error); } } export { createitem }; you can similarly implement functions for updating and deleting items using the appropriate http methods (put/post for updates and delete for removals) integrate these functions into your react native components as needed to complete your crud operations step 5 – enhancing backend security configuring access control lists (acls) protect your records by setting up acls for instance, to ensure that an item is only accessible by its owner async function createprivateitem(title, description, ownerid) { try { const acl = { " " { "read" false, "write" false }, \[ownerid] { "read" true, "write" true } }; const response = await fetch('https //parseapi back4app com/classes/items', { method 'post', headers { 'x parse application id' 'your application id', 'x parse rest api key' 'your rest api key', 'content type' 'application/json' }, body json stringify({ title, description, acl acl }) }); const data = await response json(); console log('private item created ', data); } catch (error) { console error('error creating private item ', error); } } export { createprivateitem }; setting class level permissions (clps) adjust the default permissions for your collections through the back4app dashboard this ensures that only authenticated users can interact with certain data types step 6 – implementing user authentication configuring user management back4app leverages a built in users collection to handle authentication in your react native app, you can manage user registration and login using rest api calls example user registration async function signup(username, password, email) { try { const response = await fetch('https //parseapi back4app com/users', { method 'post', headers { 'x parse application id' 'your application id', 'x parse rest api key' 'your rest api key', 'content type' 'application/json' }, body json stringify({ username, password, email }) }); const data = await response json(); console log('user registered successfully ', data); } catch (error) { console error('error during sign up ', error); } } export { signup }; example user login async function login(username, password) { try { const response = await fetch(`https //parseapi back4app com/login?username=${username}\&password=${password}`, { method 'get', headers { 'x parse application id' 'your application id', 'x parse rest api key' 'your rest api key' } }); const data = await response json(); console log('logged in user ', data); } catch (error) { console error('login failed ', error); } } export { login }; this approach can be extended to include password resets, session management, and additional authentication features conclusion and next steps great work! you have successfully built a react native crud application integrated with back4app in this guide, you set up a project named basic crud app reactnative , designed your data schema for items and users, and managed your backend with the back4app admin app moreover, you connected your app via rest apis and implemented vital security measures and user authentication what’s next? expand your app add more features such as advanced filtering, detailed item views, or real time data updates enhance backend capabilities explore cloud functions, third party integrations, or fine tune your access control policies keep learning check out the back4app documentation https //www back4app com/docs and additional tutorials to further refine your skills happy coding and best of luck with your react native project!