@intentsolutionsio/supabase-pack 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +73 -47
  3. package/package.json +4 -4
  4. package/skills/supabase-advanced-troubleshooting/SKILL.md +404 -200
  5. package/skills/supabase-advanced-troubleshooting/references/errors.md +11 -0
  6. package/skills/supabase-advanced-troubleshooting/references/evidence-collection-framework.md +34 -0
  7. package/skills/supabase-advanced-troubleshooting/references/examples.md +11 -0
  8. package/skills/supabase-advanced-troubleshooting/references/rls-edge-functions-realtime.md +363 -0
  9. package/skills/supabase-advanced-troubleshooting/references/systematic-isolation.md +56 -0
  10. package/skills/supabase-advanced-troubleshooting/references/timing-analysis.md +35 -0
  11. package/skills/supabase-architecture-variants/SKILL.md +395 -216
  12. package/skills/supabase-architecture-variants/references/errors.md +11 -0
  13. package/skills/supabase-architecture-variants/references/examples.md +12 -0
  14. package/skills/supabase-architecture-variants/references/serverless-and-multi-tenant.md +251 -0
  15. package/skills/supabase-architecture-variants/references/variant-a-monolith-(simple).md +44 -0
  16. package/skills/supabase-architecture-variants/references/variant-b-service-layer-(moderate).md +72 -0
  17. package/skills/supabase-architecture-variants/references/variant-c-microservice-(complex).md +81 -0
  18. package/skills/supabase-auth-storage-realtime-core/SKILL.md +471 -37
  19. package/skills/supabase-ci-integration/SKILL.md +315 -67
  20. package/skills/supabase-ci-integration/references/errors.md +10 -0
  21. package/skills/supabase-ci-integration/references/examples.md +36 -0
  22. package/skills/supabase-ci-integration/references/implementation.md +54 -0
  23. package/skills/supabase-common-errors/SKILL.md +320 -62
  24. package/skills/supabase-common-errors/references/errors.md +53 -0
  25. package/skills/supabase-common-errors/references/examples.md +23 -0
  26. package/skills/supabase-cost-tuning/SKILL.md +365 -131
  27. package/skills/supabase-cost-tuning/references/cost-estimation.md +34 -0
  28. package/skills/supabase-cost-tuning/references/cost-reduction-strategies.md +40 -0
  29. package/skills/supabase-cost-tuning/references/errors.md +11 -0
  30. package/skills/supabase-cost-tuning/references/examples.md +15 -0
  31. package/skills/supabase-data-handling/SKILL.md +378 -145
  32. package/skills/supabase-data-handling/references/errors.md +11 -0
  33. package/skills/supabase-data-handling/references/examples.md +27 -0
  34. package/skills/supabase-data-handling/references/implementation.md +223 -0
  35. package/skills/supabase-data-handling/references/retention-and-backup.md +221 -0
  36. package/skills/supabase-debug-bundle/SKILL.md +267 -73
  37. package/skills/supabase-debug-bundle/references/errors.md +12 -0
  38. package/skills/supabase-debug-bundle/references/examples.md +24 -0
  39. package/skills/supabase-debug-bundle/references/implementation.md +54 -0
  40. package/skills/supabase-deploy-integration/SKILL.md +258 -147
  41. package/skills/supabase-deploy-integration/references/errors.md +11 -0
  42. package/skills/supabase-deploy-integration/references/examples.md +21 -0
  43. package/skills/supabase-deploy-integration/references/google-cloud-run.md +36 -0
  44. package/skills/supabase-deploy-integration/references/vercel-deployment.md +35 -0
  45. package/skills/supabase-enterprise-rbac/SKILL.md +327 -160
  46. package/skills/supabase-enterprise-rbac/references/api-scoping-and-enforcement.md +255 -0
  47. package/skills/supabase-enterprise-rbac/references/errors.md +11 -0
  48. package/skills/supabase-enterprise-rbac/references/examples.md +12 -0
  49. package/skills/supabase-enterprise-rbac/references/role-implementation.md +33 -0
  50. package/skills/supabase-enterprise-rbac/references/sso-integration.md +35 -0
  51. package/skills/supabase-hello-world/SKILL.md +160 -54
  52. package/skills/supabase-incident-runbook/SKILL.md +453 -131
  53. package/skills/supabase-incident-runbook/references/errors.md +11 -0
  54. package/skills/supabase-incident-runbook/references/examples.md +10 -0
  55. package/skills/supabase-incident-runbook/references/immediate-actions-by-error-type.md +41 -0
  56. package/skills/supabase-install-auth/SKILL.md +186 -50
  57. package/skills/supabase-install-auth/references/examples.md +102 -0
  58. package/skills/supabase-known-pitfalls/SKILL.md +411 -241
  59. package/skills/supabase-known-pitfalls/references/errors.md +11 -0
  60. package/skills/supabase-known-pitfalls/references/examples.md +12 -0
  61. package/skills/supabase-load-scale/SKILL.md +346 -217
  62. package/skills/supabase-load-scale/references/capacity-planning.md +47 -0
  63. package/skills/supabase-load-scale/references/errors.md +11 -0
  64. package/skills/supabase-load-scale/references/examples.md +26 -0
  65. package/skills/supabase-load-scale/references/load-testing-with-k6.md +59 -0
  66. package/skills/supabase-load-scale/references/scaling-patterns.md +65 -0
  67. package/skills/supabase-load-scale/references/table-partitioning.md +263 -0
  68. package/skills/supabase-local-dev-loop/SKILL.md +272 -73
  69. package/skills/supabase-local-dev-loop/references/errors.md +11 -0
  70. package/skills/supabase-local-dev-loop/references/examples.md +21 -0
  71. package/skills/supabase-local-dev-loop/references/implementation.md +60 -0
  72. package/skills/supabase-migration-deep-dive/SKILL.md +338 -177
  73. package/skills/supabase-migration-deep-dive/references/backfill-versioning-rollback.md +258 -0
  74. package/skills/supabase-migration-deep-dive/references/errors.md +11 -0
  75. package/skills/supabase-migration-deep-dive/references/examples.md +12 -0
  76. package/skills/supabase-migration-deep-dive/references/implementation-plan.md +80 -0
  77. package/skills/supabase-migration-deep-dive/references/pre-migration-assessment.md +39 -0
  78. package/skills/supabase-multi-env-setup/SKILL.md +393 -152
  79. package/skills/supabase-multi-env-setup/references/configuration-structure.md +59 -0
  80. package/skills/supabase-multi-env-setup/references/errors.md +11 -0
  81. package/skills/supabase-multi-env-setup/references/examples.md +11 -0
  82. package/skills/supabase-observability/SKILL.md +318 -196
  83. package/skills/supabase-observability/references/alert-configuration.md +40 -0
  84. package/skills/supabase-observability/references/errors.md +11 -0
  85. package/skills/supabase-observability/references/examples.md +13 -0
  86. package/skills/supabase-observability/references/metrics-collection.md +65 -0
  87. package/skills/supabase-performance-tuning/SKILL.md +304 -160
  88. package/skills/supabase-performance-tuning/references/caching-strategy.md +49 -0
  89. package/skills/supabase-performance-tuning/references/errors.md +11 -0
  90. package/skills/supabase-performance-tuning/references/examples.md +13 -0
  91. package/skills/supabase-policy-guardrails/SKILL.md +248 -221
  92. package/skills/supabase-policy-guardrails/references/ci-cost-security.md +484 -0
  93. package/skills/supabase-policy-guardrails/references/errors.md +11 -0
  94. package/skills/supabase-policy-guardrails/references/eslint-rules.md +46 -0
  95. package/skills/supabase-policy-guardrails/references/examples.md +10 -0
  96. package/skills/supabase-prod-checklist/SKILL.md +474 -84
  97. package/skills/supabase-prod-checklist/references/errors.md +63 -0
  98. package/skills/supabase-prod-checklist/references/examples.md +153 -0
  99. package/skills/supabase-prod-checklist/references/implementation.md +113 -0
  100. package/skills/supabase-rate-limits/SKILL.md +311 -98
  101. package/skills/supabase-rate-limits/references/errors.md +11 -0
  102. package/skills/supabase-rate-limits/references/examples.md +46 -0
  103. package/skills/supabase-rate-limits/references/implementation.md +66 -0
  104. package/skills/supabase-reference-architecture/SKILL.md +249 -182
  105. package/skills/supabase-reference-architecture/references/errors.md +29 -0
  106. package/skills/supabase-reference-architecture/references/examples.md +116 -0
  107. package/skills/supabase-reference-architecture/references/key-components.md +244 -0
  108. package/skills/supabase-reference-architecture/references/project-structure.md +109 -0
  109. package/skills/supabase-reliability-patterns/SKILL.md +229 -234
  110. package/skills/supabase-reliability-patterns/references/circuit-breaker.md +36 -0
  111. package/skills/supabase-reliability-patterns/references/dead-letter-queue.md +48 -0
  112. package/skills/supabase-reliability-patterns/references/errors.md +11 -0
  113. package/skills/supabase-reliability-patterns/references/examples.md +11 -0
  114. package/skills/supabase-reliability-patterns/references/idempotency-keys.md +36 -0
  115. package/skills/supabase-reliability-patterns/references/offline-degradation-health-dualwrite.md +489 -0
  116. package/skills/supabase-schema-from-requirements/SKILL.md +373 -34
  117. package/skills/supabase-sdk-patterns/SKILL.md +388 -99
  118. package/skills/supabase-sdk-patterns/references/errors.md +11 -0
  119. package/skills/supabase-sdk-patterns/references/examples.md +45 -0
  120. package/skills/supabase-sdk-patterns/references/implementation.md +67 -0
  121. package/skills/supabase-security-basics/SKILL.md +282 -102
  122. package/skills/supabase-security-basics/references/errors.md +10 -0
  123. package/skills/supabase-security-basics/references/examples.md +70 -0
  124. package/skills/supabase-security-basics/references/implementation.md +39 -0
  125. package/skills/supabase-upgrade-migration/SKILL.md +248 -66
  126. package/skills/supabase-upgrade-migration/references/errors.md +10 -0
  127. package/skills/supabase-upgrade-migration/references/examples.md +51 -0
  128. package/skills/supabase-upgrade-migration/references/implementation.md +29 -0
  129. package/skills/supabase-webhooks-events/SKILL.md +412 -138
  130. package/skills/supabase-webhooks-events/references/errors.md +55 -0
  131. package/skills/supabase-webhooks-events/references/event-handler-pattern.md +106 -0
  132. package/skills/supabase-webhooks-events/references/examples.md +133 -0
  133. package/skills/supabase-webhooks-events/references/signature-verification.md +165 -0
@@ -0,0 +1,10 @@
1
+ ## Examples
2
+
3
+ ### One-Line Health Check
4
+
5
+ ```bash
6
+ curl -sf https://api.yourapp.com/health | jq '.services.supabase.status' || echo "UNHEALTHY"
7
+ ```
8
+
9
+ ---
10
+ *[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
@@ -0,0 +1,41 @@
1
+ # Immediate Actions By Error Type
2
+
3
+ ## Immediate Actions by Error Type
4
+
5
+ ### 401/403 - Authentication
6
+
7
+ ```bash
8
+ # Verify API key is set
9
+ kubectl get secret supabase-secrets -o jsonpath='{.data.api-key}' | base64 -d
10
+
11
+ # Check if key was rotated
12
+ # → Verify in Supabase dashboard
13
+
14
+ # Remediation: Update secret and restart pods
15
+ kubectl create secret generic supabase-secrets --from-literal=api-key=NEW_KEY --dry-run=client -o yaml | kubectl apply -f -
16
+ kubectl rollout restart deployment/supabase-integration
17
+ ```
18
+
19
+ ### 429 - Rate Limited
20
+
21
+ ```bash
22
+ # Check rate limit headers
23
+ curl -v https://api.supabase.com 2>&1 | grep -i rate
24
+
25
+ # Enable request queuing
26
+ kubectl set env deployment/supabase-integration RATE_LIMIT_MODE=queue
27
+
28
+ # Long-term: Contact Supabase for limit increase
29
+ ```
30
+
31
+ ### 500/503 - Supabase Errors
32
+
33
+ ```bash
34
+ # Enable graceful degradation
35
+ kubectl set env deployment/supabase-integration SUPABASE_FALLBACK=true
36
+
37
+ # Notify users of degraded service
38
+ # Update status page
39
+
40
+ # Monitor Supabase status for resolution
41
+ ```
@@ -1,90 +1,226 @@
1
1
  ---
2
2
  name: supabase-install-auth
3
- description: |
4
- Install and configure Supabase SDK/CLI authentication.
5
- Use when setting up a new Supabase integration, configuring API keys,
6
- or initializing Supabase in your project.
7
- Trigger with phrases like "install supabase", "setup supabase",
8
- "supabase auth", "configure supabase API key".
9
- allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(pip:*), Grep
3
+ description: 'Install and configure Supabase SDK, CLI, and project authentication.
4
+
5
+ Use when setting up a new Supabase project, installing @supabase/supabase-js,
6
+
7
+ configuring environment variables, or initializing the Supabase client.
8
+
9
+ Trigger with "install supabase", "setup supabase", "supabase auth config",
10
+
11
+ "configure supabase", "supabase init", "add supabase to project".
12
+
13
+ '
14
+ allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(npx:*), Bash(pnpm:*), Bash(pip:*),
15
+ Bash(supabase:*), Grep, Glob
10
16
  version: 1.0.0
11
17
  license: MIT
12
18
  author: Jeremy Longshore <jeremy@intentsolutions.io>
19
+ tags:
20
+ - saas
21
+ - supabase
22
+ - setup
23
+ - authentication
24
+ - sdk
25
+ compatibility: Designed for Claude Code, also compatible with Codex and OpenClaw
13
26
  ---
14
-
15
27
  # Supabase Install & Auth
16
28
 
17
29
  ## Overview
18
- Set up Supabase SDK/CLI and configure authentication credentials.
30
+
31
+ Install the Supabase SDK, CLI, and project credentials from scratch — covering package install, environment configuration, client initialization, and connection verification for both TypeScript (`@supabase/supabase-js`) and Python (`supabase`).
32
+
33
+ **Key facts:**
34
+
35
+ - **npm package:** `@supabase/supabase-js`
36
+ - **Python package:** `supabase` (via pip)
37
+ - **Client factory:** `createClient()` — never `new SupabaseClient()`
38
+ - **Dashboard:** https://supabase.com/dashboard (Settings > API for keys)
39
+ - **Docs:** https://supabase.com/docs
19
40
 
20
41
  ## Prerequisites
21
- - Node.js 18+ or Python 3.10+
22
- - Package manager (npm, pnpm, or pip)
23
- - Supabase account with API access
24
- - API key from Supabase dashboard
42
+
43
+ - Node.js 18+ (for JS/TS) or Python 3.8+ (for Python)
44
+ - Package manager: npm, pnpm, or yarn (JS) / pip (Python)
45
+ - A Supabase project created at https://supabase.com/dashboard
46
+ - Docker Desktop (only if using local development via `supabase start`)
25
47
 
26
48
  ## Instructions
27
49
 
28
- ### Step 1: Install SDK
50
+ ### Step 1 Install the SDK and CLI
51
+
52
+ Install the SDK and the Supabase CLI:
53
+
54
+ **JavaScript / TypeScript:**
55
+
29
56
  ```bash
30
- # Node.js
57
+ # Install the SDK
31
58
  npm install @supabase/supabase-js
32
59
 
33
- # Python
60
+ # For SSR frameworks (Next.js, SvelteKit, Nuxt), also install:
61
+ npm install @supabase/ssr
62
+
63
+ # Install the Supabase CLI (for types, migrations, local dev)
64
+ npm install -D supabase
65
+ ```
66
+
67
+ **Python:**
68
+
69
+ ```bash
70
+ # Install the SDK
34
71
  pip install supabase
72
+
73
+ # Install the CLI (alternative: brew install supabase/tap/supabase)
74
+ npm install -g supabase
35
75
  ```
36
76
 
37
- ### Step 2: Configure Authentication
77
+ Verify the CLI is available:
78
+
38
79
  ```bash
39
- # Set environment variable
40
- export SUPABASE_API_KEY="your-api-key"
80
+ npx supabase --version
81
+ ```
41
82
 
42
- # Or create .env file
43
- echo 'SUPABASE_API_KEY=your-api-key' >> .env
83
+ ### Step 2 Configure Environment Variables
84
+
85
+ Retrieve project credentials from the Supabase Dashboard (Settings > API) and create the env file:
86
+
87
+ ```bash
88
+ # .env.local (or .env)
89
+ SUPABASE_URL=https://<project-ref>.supabase.co
90
+ SUPABASE_KEY=eyJhbGciOiJIUzI1NiIs... # anon key — safe for client-side
91
+ SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1... # admin key — server-side ONLY
44
92
  ```
45
93
 
46
- ### Step 3: Verify Connection
47
- ```typescript
48
- const result = await supabase.from('_test').select('*').limit(1); console.log(result.error ? 'Failed' : 'OK');
94
+ Add env files to `.gitignore` immediately:
95
+
96
+ ```
97
+ .env
98
+ .env.local
99
+ .env.*.local
49
100
  ```
50
101
 
51
- ## Output
52
- - Installed SDK package in node_modules or site-packages
53
- - Environment variable or .env file with API key
54
- - Successful connection verification output
102
+ **Security rules:**
55
103
 
56
- ## Error Handling
57
- | Error | Cause | Solution |
58
- |-------|-------|----------|
59
- | Invalid API Key | Incorrect or expired key | Verify key in Supabase dashboard |
60
- | Rate Limited | Exceeded quota | Check quota at https://supabase.com/docs |
61
- | Network Error | Firewall blocking | Ensure outbound HTTPS allowed |
62
- | Module Not Found | Installation failed | Run `npm install` or `pip install` again |
104
+ - The **anon key** (`SUPABASE_KEY`) is safe for client-side code. It respects Row Level Security (RLS) policies.
105
+ - The **service role key** (`SUPABASE_SERVICE_ROLE_KEY`) bypasses RLS entirely. Use only on the server. Never bundle into client code or expose in browser.
63
106
 
64
- ## Examples
107
+ ### Step 3 — Initialize the Client and Verify
108
+
109
+ Create a client singleton and verify connectivity:
110
+
111
+ **TypeScript — client-side (anon key):**
65
112
 
66
- ### TypeScript Setup
67
113
  ```typescript
68
- import { SupabaseClient } from '@supabase/supabase-js';
114
+ // lib/supabase.ts
115
+ import { createClient } from '@supabase/supabase-js'
116
+
117
+ const supabase = createClient(
118
+ process.env.SUPABASE_URL!,
119
+ process.env.SUPABASE_KEY!
120
+ )
69
121
 
70
- const client = new SupabaseClient({
71
- apiKey: process.env.SUPABASE_API_KEY,
72
- });
122
+ export default supabase
73
123
  ```
74
124
 
75
- ### Python Setup
76
- ```python
77
- from supabase import SupabaseClient
125
+ **TypeScript server-side (service role key):**
78
126
 
79
- client = SupabaseClient(
80
- api_key=os.environ.get('SUPABASE_API_KEY')
127
+ ```typescript
128
+ // lib/supabase-admin.ts
129
+ import { createClient } from '@supabase/supabase-js'
130
+
131
+ export const supabaseAdmin = createClient(
132
+ process.env.SUPABASE_URL!,
133
+ process.env.SUPABASE_SERVICE_ROLE_KEY!,
134
+ {
135
+ auth: {
136
+ autoRefreshToken: false,
137
+ persistSession: false,
138
+ },
139
+ }
81
140
  )
82
141
  ```
83
142
 
143
+ **Python — client initialization:**
144
+
145
+ ```python
146
+ # lib/supabase_client.py
147
+ import os
148
+ from supabase import create_client
149
+
150
+ url = os.environ["SUPABASE_URL"]
151
+ key = os.environ["SUPABASE_KEY"]
152
+
153
+ supabase = create_client(url, key)
154
+ ```
155
+
156
+ **Verify the connection:**
157
+
158
+ ```typescript
159
+ // Quick connectivity check
160
+ const { data, error } = await supabase.from('_health_check').select('*').limit(1)
161
+ if (error && error.code !== 'PGRST116') {
162
+ // PGRST116 = relation does not exist (expected if table doesn't exist yet)
163
+ throw new Error(`Supabase connection failed: ${error.message}`)
164
+ }
165
+ console.log('Supabase connected successfully')
166
+ ```
167
+
168
+ **Optional — generate TypeScript types from the database schema:**
169
+
170
+ ```text
171
+ npx supabase login
172
+ npx supabase link --project-ref <your-project-ref>
173
+ npx supabase gen types typescript --linked > lib/database.types.ts
174
+ ```
175
+
176
+ Then add the type parameter to the client:
177
+
178
+ ```typescript
179
+ import type { Database } from './database.types'
180
+ const supabase = createClient<Database>(url, key)
181
+ ```
182
+
183
+ ## Output
184
+
185
+ Completing all three steps produces:
186
+
187
+ - `@supabase/supabase-js` or `supabase` Python package installed
188
+ - Supabase CLI available via `npx supabase`
189
+ - `.env.local` containing `SUPABASE_URL`, `SUPABASE_KEY`, and `SUPABASE_SERVICE_ROLE_KEY`
190
+ - Client singleton module (`lib/supabase.ts` or `lib/supabase_client.py`)
191
+ - Server-side admin client (`lib/supabase-admin.ts`, TypeScript only)
192
+ - Verified connectivity to the Supabase project
193
+
194
+ ## Error Handling
195
+
196
+ | Error | Cause | Fix |
197
+ |-------|-------|-----|
198
+ | `FetchError: request failed` | Wrong `SUPABASE_URL` | Verify URL at Dashboard > Settings > API |
199
+ | `Invalid API key` | Wrong or expired key | Copy fresh anon key from Dashboard > Settings > API |
200
+ | `PGRST301: JWSError` | Malformed JWT in key | Remove trailing whitespace/newlines from env var |
201
+ | `Cannot find module '@supabase/supabase-js'` | SDK not installed | Run `npm install @supabase/supabase-js` |
202
+ | `ModuleNotFoundError: No module named 'supabase'` | Python SDK not installed | Run `pip install supabase` |
203
+ | `supabase: command not found` | CLI not installed | Run `npm install -D supabase`, then use `npx supabase` |
204
+ | `Error: supabase start` fails | Docker not running | Start Docker Desktop, then retry `npx supabase start` |
205
+ | `TypeError: SupabaseClient is not a constructor` | Wrong import pattern | Use `createClient()` — not `new SupabaseClient()` |
206
+
207
+ ## Examples
208
+
209
+ Full TypeScript and Python examples with auth sign-up, sign-in, session management, SSR patterns, and type-safe queries: [examples](references/examples.md)
210
+
84
211
  ## Resources
85
- - [Supabase Documentation](https://supabase.com/docs)
86
- - [Supabase Dashboard](https://api.supabase.com)
87
- - [Supabase Status](https://status.supabase.com)
212
+
213
+ - [Supabase JS Client Reference](https://supabase.com/docs/reference/javascript/initializing) — `createClient` options, auth, database, storage, realtime
214
+ - [Supabase Python Client Reference](https://supabase.com/docs/reference/python/initializing) — Python SDK setup and usage
215
+ - [Supabase CLI Reference](https://supabase.com/docs/reference/cli/introduction) — local dev, migrations, type generation
216
+ - [Supabase Auth Guide](https://supabase.com/docs/guides/auth) — email/password, OAuth, magic links, RLS
217
+ - [Generating TypeScript Types](https://supabase.com/docs/guides/api/rest/generating-types) — type-safe database queries
218
+ - [Supabase Dashboard](https://supabase.com/dashboard) — project settings, API keys, database editor
88
219
 
89
220
  ## Next Steps
90
- After successful auth, proceed to `supabase-hello-world` for your first API call.
221
+
222
+ After successful setup, continue with:
223
+
224
+ - **supabase-hello-world** — run your first database query
225
+ - **supabase-rls-policies** — secure your tables with Row Level Security
226
+ - **supabase-email-auth** — set up email/password authentication flows
@@ -0,0 +1,102 @@
1
+ # Supabase Install & Auth — Examples
2
+
3
+ ## TypeScript — Full setup with auth
4
+
5
+ ```typescript
6
+ import { createClient } from '@supabase/supabase-js'
7
+
8
+ const supabase = createClient(
9
+ process.env.SUPABASE_URL!,
10
+ process.env.SUPABASE_KEY!
11
+ )
12
+
13
+ // Sign up a new user
14
+ const { data: signUp, error: signUpError } = await supabase.auth.signUp({
15
+ email: 'user@example.com',
16
+ password: 'secure-password-123',
17
+ })
18
+
19
+ // Sign in an existing user
20
+ const { data: signIn, error: signInError } = await supabase.auth.signInWithPassword({
21
+ email: 'user@example.com',
22
+ password: 'secure-password-123',
23
+ })
24
+
25
+ // Get the current session
26
+ const { data: { session } } = await supabase.auth.getSession()
27
+ console.log('Logged in as:', session?.user.email)
28
+
29
+ // Sign out
30
+ await supabase.auth.signOut()
31
+ ```
32
+
33
+ ## Python — Full setup with auth
34
+
35
+ ```python
36
+ import os
37
+ from supabase import create_client
38
+
39
+ url = os.environ["SUPABASE_URL"]
40
+ key = os.environ["SUPABASE_KEY"]
41
+ supabase = create_client(url, key)
42
+
43
+ # Sign up a new user
44
+ result = supabase.auth.sign_up({
45
+ "email": "user@example.com",
46
+ "password": "secure-password-123",
47
+ })
48
+
49
+ # Sign in an existing user
50
+ result = supabase.auth.sign_in_with_password({
51
+ "email": "user@example.com",
52
+ "password": "secure-password-123",
53
+ })
54
+
55
+ # Get the current session
56
+ session = supabase.auth.get_session()
57
+ print(f"Logged in as: {session.user.email}")
58
+
59
+ # Sign out
60
+ supabase.auth.sign_out()
61
+ ```
62
+
63
+ ## TypeScript — SSR with Next.js App Router
64
+
65
+ ```typescript
66
+ // app/lib/supabase-server.ts
67
+ import { createClient } from '@supabase/supabase-js'
68
+ import { cookies } from 'next/headers'
69
+
70
+ export function createServerClient() {
71
+ const cookieStore = cookies()
72
+ return createClient(
73
+ process.env.SUPABASE_URL!,
74
+ process.env.SUPABASE_KEY!,
75
+ {
76
+ auth: {
77
+ persistSession: false,
78
+ },
79
+ }
80
+ )
81
+ }
82
+ ```
83
+
84
+ ## TypeScript — Type-safe client with generated types
85
+
86
+ ```typescript
87
+ import { createClient } from '@supabase/supabase-js'
88
+ import type { Database } from './database.types'
89
+
90
+ const supabase = createClient<Database>(
91
+ process.env.SUPABASE_URL!,
92
+ process.env.SUPABASE_KEY!
93
+ )
94
+
95
+ // Fully typed query — IDE autocomplete for table and column names
96
+ const { data: users, error } = await supabase
97
+ .from('profiles')
98
+ .select('id, username, avatar_url')
99
+ .eq('is_active', true)
100
+ .order('created_at', { ascending: false })
101
+ .limit(10)
102
+ ```