Skip to content

Commit a9875fc

Browse files
use neon auth v2
1 parent c9ff120 commit a9875fc

24 files changed

+1252
-776
lines changed

.env.example

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# NEON_DATA_API_URL, required, the URL of your Neon Data API
22
VITE_NEON_DATA_API_URL=https://data-api-url
3-
# PUBLIC_STACK_PROJECT_ID, required, your Stack Auth project id
4-
VITE_PUBLIC_STACK_PROJECT_ID=432a953b-30fb-4fbf-a73d-c0294dc5fdf5
5-
# PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY, required, your Stack Auth publishable client key
6-
VITE_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=pck_mf296kj2dky278d62bkyefs63w3w492qgajcwx55v13bg
3+
# NEON_AUTH_URL, required, your Neon Auth URL
4+
VITE_NEON_AUTH_URL=https://neon-auth-url
75

86
# DATABASE_URL, optional, only if you want to run drizzle migrations with bun db:migrate
97
DATABASE_URL=your-database-url

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ Follow these steps to run the demo:
4141
VITE_NEON_DATA_API_URL=your_neon_data_api_url
4242
4343
# Neon Auth
44-
VITE_PUBLIC_STACK_PROJECT_ID=your_project_id
45-
VITE_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=your_client_key
44+
VITE_NEON_AUTH_URL=your_neon_auth_url
4645
```
4746

4847
Optionally, you can configure a `DATABASE_URL` environment variable and run `bun run db:migrate` to migrate your database.
@@ -79,6 +78,6 @@ This application is configured for deployment on Vercel:
7978
1. Push your code to a Git repository
8079
2. Import the project in Vercel
8180
3. Configure environment variables:
82-
- Neon Data API credentials
83-
- Neon Auth credentials
81+
- `VITE_NEON_DATA_API_URL`: Neon Data API URL
82+
- `VITE_NEON_AUTH_URL`: Neon Auth URL
8483
4. Deploy!

bun.lock

Lines changed: 661 additions & 435 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,39 @@
1515
"prettier-check": "prettier --check ."
1616
},
1717
"dependencies": {
18-
"@radix-ui/react-slot": "^1.2.0",
19-
"@radix-ui/react-toggle": "^1.1.6",
20-
"@stackframe/react": "^2.8.8",
21-
"@supabase/postgrest-js": "^1.19.4",
22-
"@tailwindcss/vite": "^4.1.4",
23-
"@tanstack/react-query": "^5.74.4",
24-
"@tanstack/react-router": "^1.117.1",
18+
"@neondatabase/neon-js": "^0.1.0-alpha.6",
19+
"@neondatabase/serverless": "^1.0.2",
20+
"@radix-ui/react-slot": "^1.2.4",
21+
"@radix-ui/react-toggle": "^1.1.10",
22+
"@tailwindcss/vite": "^4.1.17",
23+
"@tanstack/react-query": "^5.90.11",
24+
"@tanstack/react-router": "^1.139.10",
2525
"class-variance-authority": "^0.7.1",
2626
"clsx": "^2.1.1",
27-
"drizzle-kit": "^0.31.0",
28-
"drizzle-orm": "^0.43.1",
29-
"@neondatabase/serverless": "^0.10.4",
27+
"drizzle-kit": "^0.31.7",
28+
"drizzle-orm": "^0.44.7",
3029
"lucide-react": "^0.503.0",
3130
"moment": "^2.30.1",
32-
"react": "^19.0.0",
33-
"react-dom": "^19.0.0",
34-
"tailwind-merge": "^3.2.0",
35-
"tailwindcss": "^4.1.4",
31+
"react": "^19.2.0",
32+
"react-dom": "^19.2.0",
33+
"tailwind-merge": "^3.4.0",
34+
"tailwindcss": "^4.1.17",
3635
"unique-names-generator": "^4.7.1"
3736
},
3837
"devDependencies": {
3938
"@biomejs/biome": "1.9.4",
40-
"@tanstack/react-router-devtools": "^1.117.1",
41-
"@tanstack/router-plugin": "^1.117.2",
42-
"@types/node": "^22.15.2",
43-
"@types/react": "^19.0.10",
44-
"@types/react-dom": "^19.0.4",
45-
"@vitejs/plugin-react": "^4.3.4",
46-
"dotenv": "^16.5.0",
47-
"globals": "^16.0.0",
39+
"@tanstack/react-router-devtools": "^1.139.10",
40+
"@tanstack/router-plugin": "^1.139.10",
41+
"@types/node": "^22.19.1",
42+
"@types/react": "^19.2.7",
43+
"@types/react-dom": "^19.2.3",
44+
"@vitejs/plugin-react": "^4.7.0",
45+
"dotenv": "^16.6.1",
46+
"globals": "^16.5.0",
4847
"prettier": "3.5.3",
49-
"tsx": "^4.19.3",
50-
"tw-animate-css": "^1.2.8",
51-
"typescript": "~5.7.2",
52-
"vite": "^6.3.1"
48+
"tsx": "^4.20.6",
49+
"tw-animate-css": "^1.4.0",
50+
"typescript": "~5.7.3",
51+
"vite": "^6.4.1"
5352
}
5453
}

src/access-token-context.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/access-token-provider.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/app.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
22
import { RouterProvider, createRouter } from "@tanstack/react-router";
3-
import { StrictMode, useContext } from "react";
3+
import { StrictMode } from "react";
44

55
// Import the generated route tree
66
import { routeTree } from "./routeTree.gen";
77

8-
import { AccessTokenProvider } from "@/access-token-provider";
9-
import { stackClientApp } from "@/lib/stack";
10-
import { StackProvider } from "@stackframe/react";
11-
import { AccessTokenContext } from "./access-token-context";
12-
138
// Create a new router instance
149
const router = createRouter({
1510
routeTree,
@@ -33,20 +28,14 @@ function App() {
3328
return (
3429
<StrictMode>
3530
<QueryClientProvider client={queryClient}>
36-
<StackProvider app={stackClientApp}>
37-
<AccessTokenProvider>
38-
<RouterWithAuth />
39-
</AccessTokenProvider>
40-
</StackProvider>
31+
<RouterWithAuth />
4132
</QueryClientProvider>
4233
</StrictMode>
4334
);
4435
}
4536

4637
function RouterWithAuth() {
47-
const accessToken = useContext(AccessTokenContext);
48-
49-
return <RouterProvider router={router} context={{ accessToken }} />;
38+
return <RouterProvider router={router} />;
5039
}
5140

5241
export default App;

src/components/app/header.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
import type { CurrentUser } from "@stackframe/react";
1+
import { client } from "@/lib/auth";
2+
import { useRouter } from "@tanstack/react-router";
23

3-
export default function Header({ user }: { user: CurrentUser }) {
4+
export default function Header({ name }: { name: string }) {
5+
const router = useRouter();
46
return (
57
<header className="flex flex-col gap-6 mb-14">
68
<div className="flex items-center justify-between">
7-
<h3>Welcome {user.displayName?.split(" ")[0]}</h3>
9+
<h3>Welcome {name}</h3>
810
<button
911
type="button"
1012
className="text-foreground/70 font-normal cursor-pointer"
11-
onClick={() => user.signOut()}
13+
onClick={async () => {
14+
await client.auth.signOut();
15+
router.navigate({ to: "/signin" });
16+
}}
1217
>
1318
Sign out
1419
</button>

src/components/app/note-header.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NoteTitle } from "@/components/app/note-title";
22
import { Toggle } from "@/components/ui/toggle";
33
import { Note } from "@/lib/api";
4-
import { usePostgrest } from "@/lib/postgrest";
4+
import { client } from "@/lib/auth";
55
import { useMutation, useQueryClient } from "@tanstack/react-query";
66
import { Share2 } from "lucide-react";
77
import { useEffect, useState } from "react";
@@ -23,8 +23,6 @@ export default function NoteHeader({
2323
user_id,
2424
onShareToggle,
2525
}: Props) {
26-
const postgrest = usePostgrest();
27-
2826
// Optimistic UI state for shared toggle
2927
const [optimisticShared, setOptimisticShared] = useState<boolean | null>(
3028
null,
@@ -43,7 +41,7 @@ export default function NoteHeader({
4341

4442
const toggleShareMutation = useMutation({
4543
mutationFn: async (newSharedState: boolean) => {
46-
const { error } = await postgrest
44+
const { error } = await client
4745
.from("notes")
4846
.update({
4947
shared: newSharedState,

src/components/app/note-title.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Note } from "@/lib/api";
2-
import { usePostgrest } from "@/lib/postgrest";
2+
import { client } from "@/lib/auth";
33
import { useQueryClient } from "@tanstack/react-query";
44
import { Copy } from "lucide-react";
55
import { type KeyboardEvent, useEffect, useRef, useState } from "react";
@@ -18,7 +18,6 @@ export function NoteTitle({
1818
const [isEditingTitle, setIsEditingTitle] = useState(false);
1919
const [titleValue, setTitleValue] = useState(title);
2020
const titleRef = useRef<HTMLHeadingElement>(null);
21-
const postgrest = usePostgrest();
2221

2322
// Focus title when editing
2423
useEffect(() => {
@@ -52,7 +51,7 @@ export function NoteTitle({
5251
const newTitle = titleRef.current.textContent.trim();
5352
if (newTitle !== title) {
5453
try {
55-
const { error } = await postgrest
54+
const { error } = await client
5655
.from("notes")
5756
.update({ title: newTitle })
5857
.eq("id", id);

0 commit comments

Comments
 (0)