S
Supabase•2w ago
aith

Anon and Service key for Supabase local

I am running supabase locally but having a bit of trouble understanding how I can connect it to remove vs production. So, I have a .env.local. And a client.ts which creates a supabase instance like this:
export const supabase = createClient<Database>(
SUPABASE_URL,
SUPABASE_ANON_KEY,
{
auth: {
storage: customStorage,
persistSession: true,
autoRefreshToken: true
}
}
);
export const supabase = createClient<Database>(
SUPABASE_URL,
SUPABASE_ANON_KEY,
{
auth: {
storage: customStorage,
persistSession: true,
autoRefreshToken: true
}
}
);
How do I check what the ANON_KEY , service_role and PUBLISHABLE_KEY are for my local development?
6 Replies
silentworks
silentworks•2w ago
If you are using the CLI when you run supabase start it should show you the keys to use.
aith
aithOP•2w ago
I see "secret key" and "publishable key". Is this the anon key(secret key)? From the actual dashboard of production environment, I can see that the anon key and the service_role key both have a different structure (JWT). However the ones printed in the CLI are like: sb_publishable_ and sb_secret_
aith
aithOP•2w ago
These are printed when I do supabase start
No description
ibrahim
ibrahim•2w ago
supabase has moved away from using anon/service role key to publishable/secret key so you might want to use SUPABASE_PUBLISHABLE_KEY above (though for environemnt variables the naming shouldn't matter). This guide may be helpful https://supabase.com/docs/guides/api/api-keys
Understanding API keys | Supabase Docs
First-layer protection for your project's data
ibrahim
ibrahim•2w ago
for implementation purposes they work more or less the same
aantti
aantti•2w ago
(also if you'd prefer to use the old keys for some reason - npx supabase status -o env will show the old keys; the api-keys docs above is essential to read! 🙂 there's a transition from old keys to new keys, so still makes sense to switch already)

Did you find this page helpful?