Workaround

How to migrate users from Lovable Cloud (with passwords)

Lovable Cloud is making things easier, and now you can export your users with passwords and migrate them to your own Supabase. Here is how.

March 21, 20264 min206 views
#supabase#lovable#claude-code
📌Before you start

Update (May 2026): Great news - password migration is now much simpler. The Lovable MCP lets you read encrypted_password directly from auth.users and copy the bcrypt hashes to your new Supabase. No workarounds needed. See the 2026 Migration Guide for the full process.

📌Before you start

Update (June 2026): Pulling the service_role key *out of* Lovable Cloud is a different question, and it comes up a lot. The old community trick (a temporary edge function that returns the key) now gets mixed results: some people say it still works, others say it no longer does, so it is not something to rely on. On Lovable Cloud the key is injected only at runtime and is not meant to be extracted. If you need external access, the safer paths are to front your database with an edge function (it already has server-side access), or move the project to your own Supabase, where the service_role key lives in Settings → API.

One of the biggest questions when migrating from Lovable Cloud to your own Supabase is: can I keep my users? Like, with their passwords and everything?

Lovable Cloud has been making things easier for us, and this is one of those things that just works. I tested it myself today.

What you need

  • A Lovable Cloud project with registered users
  • A new Supabase project (where you want the users to go)

Step 1: Export your users

Go to your Lovable Cloud project. Click on Cloud, then SQL editor.

Run this query:

SELECT id, email, encrypted_password, raw_user_meta_data, created_at
FROM auth.users;

You'll see all your users with their IDs, emails, and password hashes.

Click Export CSV. That's it. You have your users.

Step 2: Import into your new Supabase

This part needs a little help. Pick whichever path feels most comfortable:

If you use Lovable

In your new project (connected to your own Supabase), prompt Lovable:

I need to import users into my Supabase auth system. For each user below,
use supabase.auth.admin.createUser with their id, email, password_hash,
and set email_confirm to true.

Here are the users:
- id: 90c45e08-..., email: user@email.com, password_hash: $2a$10$ddMBei...
- id: e3b88dc9-..., email: user2@email.com, password_hash: $2a$10$86TEa1...

Paste your users from the CSV. Lovable will create an edge function that imports them.

If you use Claude Code

Even simpler. Just tell Claude Code:

Import the users from this CSV into my Supabase project
using createUser with password_hash: ~/Desktop/my-export.csv

Claude Code will read the file, write the script, and run it for you.

If you're technical

Create a folder and set it up:

mkdir user-migration && cd user-migration
npm init -y
npm install @supabase/supabase-js csv-parser

Add "type": "module" to your package.json.

Create migrate.js:

import fs from 'node:fs';
import csv from 'csv-parser';
import { createClient } from '@supabase/supabase-js';

const SUPABASE_URL = 'https://your-project.supabase.co'
const SERVICE_ROLE_KEY = 'your-service-role-key-here'

const supabase = createClient(SUPABASE_URL, SERVICE_ROLE_KEY);

async function migrateUsers(filePath) {
  const users = [];

  fs.createReadStream(filePath)
    .pipe(csv({ separator: ';' }))
    .on('data', (row) => users.push(row))
    .on('end', async () => {
      console.log('Found ' + users.length + ' users. Starting migration...');

      for (const user of users) {
        try {
          const metadata = user.raw_user_meta_data
            ? JSON.parse(user.raw_user_meta_data)
            : {};

          const { data, error } = await supabase.auth.admin.createUser({
            id: user.id,
            email: user.email,
            password_hash: user.encrypted_password,
            user_metadata: metadata,
            email_confirm: true
          });

          if (error) {
            console.error('Error: ' + user.email + ' - ' + error.message);
          } else {
            console.log('Imported: ' + user.email);
          }
        } catch (parseError) {
          console.error('Failed: ' + user.email + ' - ' + parseError.message);
        }
      }
      console.log('Migration complete!');
    });
}

const csvFile = process.argv[2];
if (!csvFile) {
  console.log('Usage: node migrate.js your-export.csv');
} else {
  migrateUsers(csvFile);
}

Get your service role key from your new Supabase project: Settings, then API, then copy the service_role key. Paste it in the script.

Run it:

node migrate.js query-results-export.csv

What your users get

After the import, your users land in the new Supabase with:

  • Same user IDs (foreign keys don't break)
  • Same emails
  • Same passwords (no reset needed)
  • Same metadata

They log in with the exact same credentials. No disruption. No "please reset your password" email.

Why this matters

The biggest fear with migrating from Lovable Cloud is losing your users or forcing password resets. But Lovable Cloud is making things easier for us, the SQL editor gives you access to auth.users including encrypted passwords, and Supabase's createUser API accepts password hashes directly.

I tested this on March 21, 2026 on a live Lovable Cloud project. It works.

More resources

Enjoyed this?

Carol Ships: building, shipping, figuring it out.

Have another workaround to share?

Start the thread below!

Comments

No comments yet. Be the first to share your thoughts!