Mobile app tutorial: Connect a data source
Learn how to connect your data source by creating a resource.
The first step in building a Retool Mobile app is connecting your data source. Retool supports most databases and APIs, and you can use built-in integrations to connect to popular data sources with minimal configuration. You connect a data source by creating a resource in Retool. This guide uses a REST API as the resource.
1. Generate an API and sample data for your app
To work through the tutorial, you'll use Retool's API generator to create a test REST API with some sample data. When building your own apps, you'll often use an existing data source.
For this app, you'll generate a data set that includes the user's ID, name, email address, company, and whether the user's access is blocked. When you're ready, click the Generate API button and save the Endpoint URL.
2. Create a resource to connect your data source
Navigate to the Resources tab from the Retool homepage and click Create new > Resource. Select REST API and name the resource. In the Base URL field, paste the endpoint URL from the previous step and create the resource. When the modal is displayed, select the option to go Back to resources.
3. Create a mobile app
Navigate to the Apps tab in Retool. In the top right, select Create new -> Mobile app. Name the app Mobile User Management
and click Create app.
4. Write a test query
Queries are covered in more detail later, but it's a good idea to run one now to verify the connection to your resource. When you created the app, Retool automatically added a query. Open this query and rename it to getUsers
.
Make sure the resource you just added is selected, and that the query sends a GET request to your API. Click Run to verify the query works. You'll see a success message and a JSON response with your data.
Wrap up
Now that you have a resource you can access, it's time to start building your UI.
You can test your knowledge below or move on to the next lesson.