Guide

Build a User Management App with Svelte

Learn how to use Zuvo in your Svelte 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 Svelte app from scratch.

Initialize a Svelte app

You can use the Vite Svelte TypeScript Template to initialize an app called supabase-svelte:

npm create vite@latest supabase-svelte -- --template svelte-ts
cd supabase-svelte
npm install

Install the only additional dependency: supabase-js

npm install @supabase/supabase-js

Finally, save the environment variables in a .env. All you need are the API URL and the key that you copied earlier.

Now you have the API credentials in place, create a helper file to initialize the Zuvo client. These variables will be exposed on the browser, and that's fine since you have Row Level Security enabled on the Database.

Code sample: see project quickstart in Zuvo Studio.

App styling (optional)

Optionally, update the CSS file src/app.css to make the app look better. You can find the full contents of this file in the example repository.

Set up a login component

Set up a Svelte component to manage logins and sign ups. It 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 is signed in, allow them to edit their profile details and manage their account. Create a new component for that called Account.svelte.

Code sample: see project quickstart in Zuvo Studio.

Profile photos

Next, add a way for users to upload a profile photo. Zuvo configures every project with Storage for managing large files like photos and videos.

Create an upload widget

Start by creating a new component:

Code sample: see project quickstart in Zuvo Studio.

Update the account component

With the Avatar component created, update src/lib/Account.svelte to include it:

Code sample: see project quickstart in Zuvo Studio.

Launch!

With all the components in place, update App.svelte:

Code sample: see project quickstart in Zuvo Studio.

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

npm run dev

And then open the browser to localhost:5173 and you should see the completed app.

Zuvo Svelte

At this stage you have a fully functional application!