From 93296b8d2d0c53ec3a0b4d409955806cbdf2ac87 Mon Sep 17 00:00:00 2001 From: linkT Date: Thu, 29 Jan 2026 00:37:13 +0100 Subject: [PATCH] doc: update Next.js tutorial for Appwrite SDK v16+ compatibility - Migrated from positional to object-parameter style for database methods - Updated deprecated createRow, deleteRow, and listRows methods - Fixed TypeScript types: Models.Session to Models.User - Changed user property access: userId to \$id, providerUid to email - Added TypeScript generics for type-safe API responses - Fixed state management with proper props drilling for real-time updates - Updated import paths to use Next.js path aliases (@/) - Updated deleteSession to use object parameter style Tested with appwrite@^21.5.0 and next@^16.1.6" --- .../tutorials/nextjs/step-4/+page.markdoc | 13 ++-- .../tutorials/nextjs/step-5/+page.markdoc | 4 +- .../tutorials/nextjs/step-6/+page.markdoc | 49 ++++++++------- .../tutorials/nextjs/step-7/+page.markdoc | 62 ++++++++++++++----- 4 files changed, 83 insertions(+), 45 deletions(-) diff --git a/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc b/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc index 202b4ead8c..a37e6f2c45 100644 --- a/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs/step-4/+page.markdoc @@ -26,13 +26,13 @@ Create a new file `hooks/useAuth.ts` and add the following code. // hooks/useAuth.ts import { useState, useEffect } from 'react'; -import { account } from '../lib/appwrite'; +import { account } from '@/lib/appwrite'; import { ID } from 'appwrite'; import type { Models } from 'appwrite'; import { useRouter } from 'next/navigation'; export function useAuth() { - const [current, setCurrent] = useState(null); + const [current, setCurrent] = useState | null>(null); const [loading, setLoading] = useState(true); const router = useRouter(); @@ -46,16 +46,17 @@ export function useAuth() { }; const login = async (email: string, password: string): Promise => { - const session = await account.createEmailPasswordSession({ + await account.createEmailPasswordSession({ email, password }); - setCurrent(session); + const user = await account.get(); + setCurrent(user); router.push('/'); }; const logout = async (): Promise => { - await account.deleteSession('current'); + await account.deleteSession({ sessionId: 'current' }); setCurrent(null); router.push('/'); }; @@ -97,7 +98,7 @@ We will define functions to handle form submissions and show either a signup or 'use client'; import { useState } from 'react'; -import { useAuth } from '../../hooks/useAuth'; +import { useAuth } from '@/hooks/useAuth'; import AuthForm from '../../components/AuthForm'; export default function LoginPage() { diff --git a/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc b/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc index b896f49b77..35ea71a071 100644 --- a/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc +++ b/src/routes/docs/tutorials/nextjs/step-5/+page.markdoc @@ -18,7 +18,7 @@ Create a new file `src/components/Navbar.tsx` and add the code below. 'use client'; import Link from 'next/link'; -import { useAuth } from '../hooks/useAuth'; +import { useAuth } from '@/hooks/useAuth'; export default function Navbar() { const { current, logout } = useAuth(); @@ -28,7 +28,7 @@ export default function Navbar() {

Idea Tracker

{current ? (
-

{current.providerUid}

+

{current.name || current.email}

- {user && user.userId === idea.userId && ( + {user && user.$id === idea.userId && (