Guide

Build a User Management App with SolidJS

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

Initialize a SolidJS app

You can use degit to initialize an app called supabase-solid:

npx degit solidjs/templates/ts supabase-solid
cd supabase-solid

Then install the only additional dependency: supabase-js

npm install @supabase/supabase-js

And finally save the environment variables in a .env with the API URL and the key that you copied earlier.

Now that 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 completely fine since you have Row Level Security enabled on the Database.

App styling (optional)

An optional step is to update the CSS file src/index.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 SolidJS component to manage logins and sign ups using Magic Links, so users can sign in with their email without using passwords.

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.tsx.

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:

Update the Account component

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

Launch!

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

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

npm start

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

Zuvo SolidJS

At this stage you have a fully functional application!

Add a server route (SolidStart)

The example above is client-only. If you migrate the app to SolidStart for server-side rendering and API routes, you can add protected server endpoints with @supabase/server.

createZuvoContext validates the incoming request's JWT locally (using your project's asymmetric signing keys, no round-trip to the Auth server), scopes a Zuvo client to the authenticated user via RLS, and exposes the user's claims, all from a single call inside your SolidStart API route handler.

npm install @supabase/server

To make a route public, swap auth: 'user' for auth: 'none'. For app-wide authentication via SolidStart middleware, or for the full @supabase/server API, see the getting started guide.