@neondatabase/neon-js 0.1.0-alpha.8 → 0.1.0-beta.1

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.
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # @neondatabase/neon-js
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@neondatabase/neon-js.svg)](https://www.npmjs.com/package/@neondatabase/neon-js)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@neondatabase/neon-js.svg)](https://www.npmjs.com/package/@neondatabase/neon-js)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue.svg)](https://www.typescriptlang.org/)
6
+ [![License](https://img.shields.io/npm/l/@neondatabase/neon-js.svg)](https://github.com/neondatabase-labs/neon-js/blob/main/LICENSE)
7
+
3
8
  The official TypeScript SDK for Neon, combining authentication and database querying in a familiar interface.
4
9
 
5
10
  ## Overview
@@ -8,7 +13,7 @@ The official TypeScript SDK for Neon, combining authentication and database quer
8
13
 
9
14
  **Key Features:**
10
15
 
11
- - **Integrated Authentication** - Multiple auth adapters (Supabase-compatible, Better Auth)
16
+ - **Integrated Authentication** - Works out of the box with optional adapters (Supabase-compatible, React hooks)
12
17
  - **PostgreSQL Querying** - Full PostgREST client with type-safe queries
13
18
  - **High Performance** - Session caching, request deduplication
14
19
  - **Automatic Token Management** - Seamless token injection for database queries
@@ -25,14 +30,11 @@ bun add @neondatabase/neon-js
25
30
 
26
31
  ## Quick Start
27
32
 
28
- ### Using SupabaseAuthAdapter (Supabase-compatible API)
29
-
30
33
  ```typescript
31
- import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
34
+ import { createClient } from '@neondatabase/neon-js';
32
35
 
33
36
  const client = createClient<Database>({
34
37
  auth: {
35
- adapter: SupabaseAuthAdapter(),
36
38
  url: import.meta.env.VITE_NEON_AUTH_URL,
37
39
  },
38
40
  dataApi: {
@@ -40,27 +42,33 @@ const client = createClient<Database>({
40
42
  },
41
43
  });
42
44
 
43
- // Authenticate with Supabase-compatible API
44
- await client.auth.signInWithPassword({
45
+ // Authenticate
46
+ await client.auth.signIn.email({
45
47
  email: 'user@example.com',
46
48
  password: 'secure-password',
47
49
  });
48
50
 
49
51
  // Query database (token automatically injected)
50
- const { data: users, error } = await client
52
+ const { data: users } = await client
51
53
  .from('users')
52
54
  .select('*')
53
55
  .eq('status', 'active');
54
56
  ```
55
57
 
56
- ### Using BetterAuthVanillaAdapter (Direct Better Auth API)
58
+ ### Using Adapters
59
+
60
+ You can optionally specify an adapter for different API styles:
61
+
62
+ #### SupabaseAuthAdapter (Supabase-compatible API)
63
+
64
+ Use this adapter if you're migrating from Supabase or prefer the Supabase API style:
57
65
 
58
66
  ```typescript
59
- import { createClient, BetterAuthVanillaAdapter } from '@neondatabase/neon-js';
67
+ import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
60
68
 
61
69
  const client = createClient<Database>({
62
70
  auth: {
63
- adapter: BetterAuthVanillaAdapter(),
71
+ adapter: SupabaseAuthAdapter(),
64
72
  url: import.meta.env.VITE_NEON_AUTH_URL,
65
73
  },
66
74
  dataApi: {
@@ -68,22 +76,22 @@ const client = createClient<Database>({
68
76
  },
69
77
  });
70
78
 
71
- // Authenticate with Better Auth API
72
- await client.auth.signIn.email({
79
+ // Supabase-compatible API
80
+ await client.auth.signInWithPassword({
73
81
  email: 'user@example.com',
74
82
  password: 'secure-password',
75
83
  });
76
84
 
77
- // Query database (token automatically injected)
78
- const { data: users } = await client
79
- .from('users')
80
- .select('*');
85
+ const { data: session } = await client.auth.getSession();
81
86
  ```
82
87
 
83
- ### Using BetterAuthReactAdapter (Better Auth with React Hooks)
88
+ #### BetterAuthReactAdapter (React Hooks)
89
+
90
+ Use this adapter in React applications to get access to hooks like `useSession`:
84
91
 
85
92
  ```typescript
86
- import { createClient, BetterAuthReactAdapter } from '@neondatabase/neon-js';
93
+ import { createClient } from '@neondatabase/neon-js';
94
+ import { BetterAuthReactAdapter } from '@neondatabase/neon-js/auth/react/adapters';
87
95
 
88
96
  const client = createClient<Database>({
89
97
  auth: {
@@ -108,22 +116,7 @@ function MyComponent() {
108
116
 
109
117
  ## Authentication
110
118
 
111
- ### Sign Up (SupabaseAuthAdapter)
112
-
113
- ```typescript
114
- await client.auth.signUp({
115
- email: 'user@example.com',
116
- password: 'secure-password',
117
- options: {
118
- data: {
119
- name: 'John Doe',
120
- avatar_url: 'https://example.com/avatar.jpg',
121
- },
122
- },
123
- });
124
- ```
125
-
126
- ### Sign Up (BetterAuth Adapters)
119
+ ### Sign Up
127
120
 
128
121
  ```typescript
129
122
  await client.auth.signUp.email({
@@ -133,25 +126,7 @@ await client.auth.signUp.email({
133
126
  });
134
127
  ```
135
128
 
136
- ### Sign In (SupabaseAuthAdapter)
137
-
138
- ```typescript
139
- // Email & Password
140
- await client.auth.signInWithPassword({
141
- email: 'user@example.com',
142
- password: 'secure-password',
143
- });
144
-
145
- // OAuth
146
- await client.auth.signInWithOAuth({
147
- provider: 'google',
148
- options: {
149
- redirectTo: '/dashboard',
150
- },
151
- });
152
- ```
153
-
154
- ### Sign In (BetterAuth Adapters)
129
+ ### Sign In
155
130
 
156
131
  ```typescript
157
132
  // Email & Password
@@ -167,45 +142,49 @@ await client.auth.signIn.social({
167
142
  });
168
143
  ```
169
144
 
170
- ### Session Management (SupabaseAuthAdapter)
145
+ ### Session Management
171
146
 
172
147
  ```typescript
173
148
  // Get current session
174
- const { data: session } = await client.auth.getSession();
175
-
176
- // Get current user
177
- const { data: user } = await client.auth.getUser();
178
-
179
- // Update user
180
- await client.auth.updateUser({
181
- data: {
182
- name: 'Jane Doe',
183
- },
184
- });
149
+ const session = await client.auth.getSession();
185
150
 
186
151
  // Sign out
187
152
  await client.auth.signOut();
188
153
  ```
189
154
 
190
- ### Session Management (BetterAuth Adapters)
155
+ ### SupabaseAuthAdapter API
156
+
157
+ When using `SupabaseAuthAdapter`, you get access to the Supabase-compatible API:
191
158
 
192
159
  ```typescript
193
- // Get current session
194
- const session = await client.auth.getSession();
160
+ // Sign up with metadata
161
+ await client.auth.signUp({
162
+ email: 'user@example.com',
163
+ password: 'secure-password',
164
+ options: {
165
+ data: { name: 'John Doe' },
166
+ },
167
+ });
195
168
 
196
- // Sign out
197
- await client.auth.signOut();
198
- ```
169
+ // Sign in
170
+ await client.auth.signInWithPassword({
171
+ email: 'user@example.com',
172
+ password: 'secure-password',
173
+ });
199
174
 
200
- ### Auth State Changes (SupabaseAuthAdapter)
175
+ // OAuth
176
+ await client.auth.signInWithOAuth({
177
+ provider: 'google',
178
+ options: { redirectTo: '/dashboard' },
179
+ });
201
180
 
202
- ```typescript
181
+ // Session with data wrapper
182
+ const { data: session } = await client.auth.getSession();
183
+ const { data: user } = await client.auth.getUser();
184
+
185
+ // Auth state changes
203
186
  client.auth.onAuthStateChange((event, session) => {
204
- if (event === 'SIGNED_IN') {
205
- console.log('User signed in:', session?.user);
206
- } else if (event === 'SIGNED_OUT') {
207
- console.log('User signed out');
208
- }
187
+ console.log(event, session);
209
188
  });
210
189
  ```
211
190
 
@@ -296,12 +275,11 @@ const { data } = await client
296
275
  ### Client Options
297
276
 
298
277
  ```typescript
299
- import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
278
+ import { createClient } from '@neondatabase/neon-js';
300
279
 
301
280
  const client = createClient({
302
281
  // Auth configuration
303
282
  auth: {
304
- adapter: SupabaseAuthAdapter(),
305
283
  url: 'https://your-auth-server.neon.tech/auth',
306
284
  },
307
285
 
@@ -333,11 +311,10 @@ NEON_DATA_API_URL=https://your-data-api.neon.tech/rest/v1
333
311
  ```
334
312
 
335
313
  ```typescript
336
- import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
314
+ import { createClient } from '@neondatabase/neon-js';
337
315
 
338
316
  const client = createClient({
339
317
  auth: {
340
- adapter: SupabaseAuthAdapter(),
341
318
  url: process.env.NEON_AUTH_URL!,
342
319
  },
343
320
  dataApi: {
@@ -346,6 +323,24 @@ const client = createClient({
346
323
  });
347
324
  ```
348
325
 
326
+ ## UI Component Styles
327
+
328
+ If you're using `@neondatabase/auth-ui` components with the SDK, CSS is conveniently available:
329
+
330
+ | Export | Use Case |
331
+ |--------|----------|
332
+ | `@neondatabase/neon-js/ui/css` | Pre-built styles (~47KB) |
333
+ | `@neondatabase/neon-js/ui/tailwind` | Tailwind-ready CSS |
334
+
335
+ ```css
336
+ /* Without Tailwind */
337
+ @import '@neondatabase/neon-js/ui/css';
338
+
339
+ /* With Tailwind CSS v4 */
340
+ @import 'tailwindcss';
341
+ @import '@neondatabase/neon-js/ui/tailwind';
342
+ ```
343
+
349
344
  ## TypeScript
350
345
 
351
346
  Generate TypeScript types from your database schema:
@@ -358,11 +353,10 @@ Use generated types for full type safety:
358
353
 
359
354
  ```typescript
360
355
  import type { Database } from './types/database';
361
- import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
356
+ import { createClient } from '@neondatabase/neon-js';
362
357
 
363
358
  const client = createClient<Database>({
364
359
  auth: {
365
- adapter: SupabaseAuthAdapter(),
366
360
  url: process.env.NEON_AUTH_URL!,
367
361
  },
368
362
  dataApi: {
@@ -450,11 +444,10 @@ if (error) {
450
444
 
451
445
  ```typescript
452
446
  // app/lib/neon.ts
453
- import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
447
+ import { createClient } from '@neondatabase/neon-js';
454
448
 
455
449
  export const neon = createClient({
456
450
  auth: {
457
- adapter: SupabaseAuthAdapter(),
458
451
  url: process.env.NEON_AUTH_URL!,
459
452
  },
460
453
  dataApi: {
@@ -474,7 +467,8 @@ export async function GET() {
474
467
  ### React Hook with BetterAuthReactAdapter
475
468
 
476
469
  ```typescript
477
- import { createClient, BetterAuthReactAdapter } from '@neondatabase/neon-js';
470
+ import { createClient } from '@neondatabase/neon-js';
471
+ import { BetterAuthReactAdapter } from '@neondatabase/neon-js/auth/react/adapters';
478
472
 
479
473
  const client = createClient({
480
474
  auth: {
@@ -503,7 +497,7 @@ export function useAuth() {
503
497
 
504
498
  This package combines two underlying packages:
505
499
 
506
- - [`@neondatabase/neon-auth`](../neon-auth) - Authentication adapters (can be used standalone)
500
+ - [`@neondatabase/auth`](../auth) - Authentication adapters (can be used standalone)
507
501
  - [`@neondatabase/postgrest-js`](../postgrest-js) - PostgreSQL client (can be used standalone)
508
502
 
509
503
  ## Migration from Previous Version
@@ -541,7 +535,7 @@ const client = createClient({
541
535
  ## Support
542
536
 
543
537
  - [GitHub Issues](https://github.com/neondatabase/neon-js/issues)
544
- - [Neon Community Discord](https://discord.gg/neon)
538
+ - [Neon Community Discord](https://discord.gg/H24eC2UN)
545
539
 
546
540
  ## License
547
541
 
@@ -0,0 +1 @@
1
+ export * from "@neondatabase/auth";
@@ -0,0 +1,3 @@
1
+ export * from "@neondatabase/auth"
2
+
3
+ export { };
@@ -0,0 +1 @@
1
+ export * from "@neondatabase/auth/next";
@@ -0,0 +1,3 @@
1
+ export * from "@neondatabase/auth/next"
2
+
3
+ export { };
@@ -0,0 +1 @@
1
+ export * from "@neondatabase/auth/react/adapters";
@@ -0,0 +1,3 @@
1
+ export * from "@neondatabase/auth/react/adapters"
2
+
3
+ export { };
@@ -0,0 +1 @@
1
+ export * from "@neondatabase/auth/react";
@@ -0,0 +1,3 @@
1
+ export * from "@neondatabase/auth/react"
2
+
3
+ export { };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export * from "@neondatabase/auth/react/ui";
@@ -0,0 +1,4 @@
1
+ 'use client';
2
+ export * from "@neondatabase/auth/react/ui"
3
+
4
+ export { };
@@ -0,0 +1 @@
1
+ export * from "@neondatabase/auth/react/ui/server";
@@ -0,0 +1,3 @@
1
+ export * from "@neondatabase/auth/react/ui/server"
2
+
3
+ export { };
@@ -0,0 +1 @@
1
+ export * from "@neondatabase/auth/vanilla/adapters";
@@ -0,0 +1,3 @@
1
+ export * from "@neondatabase/auth/vanilla/adapters"
2
+
3
+ export { };
@@ -0,0 +1 @@
1
+ export * from "@neondatabase/auth/vanilla";
@@ -0,0 +1,3 @@
1
+ export * from "@neondatabase/auth/vanilla"
2
+
3
+ export { };