Skip to content

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

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

grdsdev merged 6 commits into
mainfrom
claude/naughty-wright-f4fec3

Conversation

@grdsdev

@grdsdev grdsdev commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

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_flutter — Supabase.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.

supabase — SupabaseClient

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

grdsdev commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@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 Resolved
…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
grdsdev added a commit to supabase/supabase that referenced this pull request May 8, 2026
## Summary

Updates reference docs based on recent **stable** releases across
supabase-js, supabase-flutter, and supabase-py. Only changes that landed
in a stable tag are documented.

## Changes analyzed

| SDK | Repo | Stable tag range | Notes |
|-----|------|-----------------|-------|
| js | supabase/supabase-js | `v2.105.0` → `v2.105.3` | Bug fixes and
type improvements; no doc-worthy API changes |
| dart | supabase/supabase-flutter | → `supabase_flutter-v2.13.0` |
`anonKey` deprecated → `publishableKey` |
| py | supabase/supabase-py | `v2.29.0` → `v2.30.0` | New: `.select()`
chaining on write builders |
| swift | supabase/supabase-swift | `v2.46.0` | Dependency bumps only |
| kt | supabase-community/supabase-kt | `3.6.0` | Test coverage
improvements only |
| csharp | supabase-community/supabase-csharp | `v1.1.2` | No changes |

> **Note**: The JS `storage.from().exists()` breaking behavior change
and `PostgrestError instanceof` fix were intentionally excluded — they
are only in the `v3.0.0-next` pre-release branch, not in any stable
`v2.x` tag.

## Documentation updates

### `apps/docs/spec/supabase_dart_v2.yml`
- Rename `anonKey` parameter → `publishableKey` in
`Supabase.initialize()` to match the deprecation in
[supabase-flutter#1360](supabase/supabase-flutter#1360)
(landed in `supabase_flutter-v2.13.0`)
- Update Flutter example to use `publishableKey:` named argument
- Note that `anonKey` is still accepted but deprecated

### `apps/docs/spec/supabase_py_v2.yml`
- Add `.select()` chaining examples to `insert()`, `update()`,
`upsert()`, and `delete()` write builders, newly supported in
[supabase-py v2.30.0](supabase/supabase-py#1383)
- Add notes to each write method mentioning select chaining capability

---

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **Documentation**
* Dart SDK: Updated client initialization to use `publishableKey`
parameter; deprecated `anonKey` remains supported for backward
compatibility.
* Python SDK: Added examples demonstrating how to chain `.select()` with
write operations (`insert()`, `update()`, `upsert()`, `delete()`) to
retrieve specific columns from modified rows.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
syouya0618 added a commit to syouya0618/irori that referenced this pull request Jun 12, 2026
…nonKey→publishableKey へ rename (Closes #9 の代替) (#51)

dependabot PR #9 (go_router 17.2.3→17.3.0 + supabase_flutter 2.12.4→2.14.2)
の代替。#9 は supabase_flutter 2.13.0 で導入された anonKey deprecation
(CHANGELOG: "FEAT: rename anon key → publishable key" supabase/supabase-flutter#1360)
により lib/main.dart:32 の deprecated_member_use info で
`flutter analyze --fatal-infos` が fail し、rebase では解消不能のため
bump + rename を本 PR に統合する。

deprecation 一次情報 (pub cache supabase_flutter-2.14.2/lib/src/supabase.dart):

  @deprecated(
    'Use publishableKey instead. anonKey will be removed in a future major version.',
  )
  String? anonKey,

内部実装は `final effectiveKey = publishableKey ?? anonKey!;` で両パラメータが
合流するだけで値の形式検証はなく、legacy anon key (JWT) / sb_publishable_
キーのどちらも同一に受けるため、rename による挙動差分はない。
env 名 SUPABASE_ANON_KEY と --dart-define の渡し方は CI / Vercel 連動のため不変。

pubspec.lock の変動 (fvm flutter pub get 生成、すべて supabase ファミリー
transitive + 直接 bump 2 件):
- supabase_flutter 2.12.4 → 2.14.2 (direct)
- go_router 17.2.3 → 17.3.0 (direct)
- supabase 2.10.6 → 2.12.2
- gotrue 2.20.0 → 2.21.0
- functions_client 2.5.0 → 2.6.0
- postgrest 2.7.0 → 2.7.1
- realtime_client 2.7.3 → 2.7.4
- storage_client 2.5.2 → 2.5.6

ゲート: fvm flutter analyze --fatal-infos (No issues) /
fvm flutter test (784 passed) /
fvm dart format --set-exit-if-changed lib test (0 changed) 全 green。

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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