Skip to content

feat: rename anon key → publishable key, service role key → secret key#1360

Merged
grdsdev merged 6 commits intomainfrom
claude/naughty-wright-f4fec3
Apr 27, 2026
Merged

feat: rename anon key → publishable key, service role key → secret key#1360
grdsdev merged 6 commits intomainfrom
claude/naughty-wright-f4fec3

Conversation

@grdsdev
Copy link
Copy Markdown
Contributor

@grdsdev grdsdev commented Apr 27, 2026

Summary

Updates API key terminology across code, tests, docs, and infra. No breaking changes — the old anonKey parameter is deprecated with a migration message pointing to the new name.

Changes

supabase_flutterSupabase.initialize()

anonKey is deprecated in favour of publishableKey. Both are accepted; publishableKey takes precedence if both are supplied.

// Before (still compiles, emits deprecation warning)
await Supabase.initialize(url: url, anonKey: key);

// After
await Supabase.initialize(url: url, publishableKey: key);

publishableKey is the right name for the Flutter package: apps run on the client and should always use the publishable (anon) key. The doc comment now explicitly warns against using the secret key here.

supabaseSupabaseClient

The positional supabaseKey parameter is kept as-is — the plain Dart package is used in both client and server contexts, so a generic name is appropriate. The doc comment is updated to clarify the distinction:

Pass the publishable (anon) key for client-side usage or the secret key for trusted server-side environments.

Doc comments — GoTrueAdminApi / GoTrueAdminOAuthApi

References to `service_role` key updated to `secret` key to match the new naming.

What was intentionally left unchanged

  • JWT role claims ('role': 'service_role') — internal backend values, unrelated to key naming
  • ANON_KEY in infra/storage_client/docker-compose.yml — the storage binary reads this env var by name; renaming it would silently break the service
  • CHANGELOG entries — historical entries are not refactored

🤖 Generated with Claude Code

grdsdev and others added 3 commits April 27, 2026 08:22
…et key

Renames all references to align with Supabase's updated key naming convention:
- `anonKey` parameter → `publishableKey` in Supabase.initialize() and _init()
- `supabaseAnonKey` → `supabasePublishableKey` (internal parameter)
- `ANON_KEY` / `SUPABASE_ANON_KEY` → `PUBLISHABLE_KEY` / `SUPABASE_PUBLISHABLE_KEY` in examples, docs, and infra config
- `service_role` key references in doc comments → `secret` key
- Test variables `anonToken` → `publishableToken` in gotrue tests

JWT role claims (`'role': 'service_role'`) are left unchanged as they are
internal backend values unrelated to the key naming convention.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nv var rename

- Keep anonKey as @deprecated in Supabase.initialize() so existing callers
  continue to compile; they receive a deprecation warning pointing to publishableKey.
  An assert enforces that at least one of the two is supplied.
- Revert ANON_KEY → PUBLISHABLE_KEY in docker-compose: the storage binary reads
  ANON_KEY by name, renaming it silently breaks the service.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev requested a review from a team April 27, 2026 11:31
@Vinzent03
Copy link
Copy Markdown
Collaborator

The SupabaseClient in the supabase package calls the argument supabaseKey. It is positional so renaming it is no breaking change, but I think it can/should also be renamed to align it with the rest and update the documentation of it.

grdsdev and others added 2 commits April 27, 2026 11:35
The key passed to Supabase.initialize() can be either a publishable key
(anon) or a secret key depending on the use case, so the parameter name
should not imply a specific key type. Aligns with SupabaseClient which
already uses supabaseKey as its positional argument.

- Rename publishableKey parameter -> supabaseKey in Supabase.initialize()
- Update deprecated anonKey message to reference supabaseKey
- Update all call sites in tests, examples, docs, and CHANGELOG
- Revert internal gotrue test variable names back to anonToken (they
  represent the anonymous JWT, unrelated to the public API rename)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…PABASE_PUBLISHABLE_KEY in example

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev changed the title feat: rename anon key → publishable key, service role key → secret key feat: rename anon key → supabase key, service role key → secret key Apr 27, 2026
@grdsdev
Copy link
Copy Markdown
Contributor Author

grdsdev commented Apr 27, 2026

@Vinzent03 I decided to go with supabaseKey in all public facing APIs, since keys can be either publishable or secret, please review it again.

@grdsdev grdsdev requested a review from Vinzent03 April 27, 2026 14:42
Comment thread packages/supabase/CHANGELOG.md
Comment thread packages/supabase_flutter/lib/src/supabase.dart Outdated
…ckage; revert CHANGELOG edits

- Supabase.initialize() (supabase_flutter): rename supabaseKey → publishableKey.
  Flutter apps are client-side and should always use the publishable (anon)
  key, matching the label shown on the Supabase dashboard.
- SupabaseClient (supabase): keep supabaseKey as-is. The dart package is used
  in both client and server contexts, so the generic name is appropriate.
- Add a note to SupabaseClient doc distinguishing publishable vs secret usage.
- Revert all CHANGELOG modifications — historical entries should not be
  refactored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev requested a review from Vinzent03 April 27, 2026 18:43
@grdsdev grdsdev changed the title feat: rename anon key → supabase key, service role key → secret key feat: rename anon key → publishable key, service role key → secret key Apr 27, 2026
@grdsdev grdsdev merged commit d4e2370 into main Apr 27, 2026
21 checks passed
@grdsdev grdsdev deleted the claude/naughty-wright-f4fec3 branch April 27, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants