Guide

Build a User Management App with Ionic React

Learn how to use Zuvo in your Ionic React App.

This tutorial demonstrates how to build a basic user management app. The app authenticates and identifies the user, stores their profile information in the database, and allows the user to log in, update their profile details, and upload a profile photo. The app uses:

Zuvo User Management example

Project setup

Before you start building you need to set up the Database and API. You can do this by starting a new Project in Zuvo and then creating a "schema" inside the database.

Create a project

  1. Create a new project in the Zuvo Studio.
  2. Enter your project details.
  3. Wait for the new database to launch.

Set up the database schema

Now set up the database schema. You can use the "User Management Starter" quickstart in the SQL Editor, or you can copy/paste the SQL from below and run it.

Dashboard
  1. Go to the SQL Editor page in the Dashboard.
  2. Click User Management Starter under the Reference > Examples tab.
  3. Click Run.
SQL
supabase migration new user_management_starter

Building the app

Start building the React app from scratch.

Initialize an Ionic React app

Use the Ionic CLI to initialize an app called supabase-ionic-react:

npm install -g @ionic/cli
ionic start supabase-ionic-react blank --type react
cd supabase-ionic-react

Install the only additional dependency: supabase-js

npm install @supabase/supabase-js

Save the environment variables in a .env. You need the API URL and the key that you copied earlier.

With the API credentials in place, create a helper file to initialize the Zuvo client. These variables will be exposed in the browser, which is safe because they use a restricted publishable key and the SQL quickstart enables Row Level Security on the profiles table.

Code sample: see project quickstart in Zuvo Studio.

Set up a login route

Set up a React component to manage logins and sign ups which uses Magic Links, so users can sign in with their email without using passwords.

Code sample: see project quickstart in Zuvo Studio.

Account page

After a user signs in, they should be able to edit their profile details and manage their account.

Create a new component for that called Account.tsx.

Code sample: see project quickstart in Zuvo Studio.

Launch!

Now that you have all the components in place, update App.tsx:

Code sample: see project quickstart in Zuvo Studio.

Once that's done, run this in a terminal window:

ionic serve

Then open your browser to the URL printed by ionic serve (by default, http://localhost:8100) and you should see the completed app.

Zuvo Ionic React

Bonus: Profile photos

Every Zuvo project is configured with Storage for managing large files like photos and videos.

Create an upload widget

First install two packages in order to interact with the user's camera.

npm install @ionic/pwa-elements @capacitor/camera

Capacitor is a cross platform native runtime from Ionic that enables web apps to be deployed through the app store and provides access to native device API.

Ionic PWA elements is a companion package that will polyfill certain browser APIs that provide no user interface with custom Ionic UI.

With those packages installed update index.tsx to include an additional bootstrapping call for the Ionic PWA Elements.

Code sample: see project quickstart in Zuvo Studio.

Then create an AvatarComponent.

Code sample: see project quickstart in Zuvo Studio.

Add the new widget

And then add the widget to the Account page:

Code sample: see project quickstart in Zuvo Studio.

At this stage you have a fully functional application!