@netlify/identity 0.1.1-alpha.18 → 0.1.1-alpha.19

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 (2) hide show
  1. package/README.md +21 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -334,24 +334,40 @@ The library also supports server-side mutations (`login()`, `signup()`, `logout(
334
334
 
335
335
  ### Next.js (App Router)
336
336
 
337
- **Login with Server Action (server-side pattern):**
337
+ **Server Actions return results; the client handles navigation:**
338
338
 
339
339
  ```tsx
340
340
  // app/actions.ts
341
341
  'use server'
342
342
  import { login, logout } from '@netlify/identity'
343
- import { redirect } from 'next/navigation'
344
343
 
345
344
  export async function loginAction(formData: FormData) {
346
345
  const email = formData.get('email') as string
347
346
  const password = formData.get('password') as string
348
347
  await login(email, password)
349
- redirect('/dashboard')
348
+ return { success: true }
350
349
  }
351
350
 
352
351
  export async function logoutAction() {
353
352
  await logout()
354
- redirect('/')
353
+ return { success: true }
354
+ }
355
+ ```
356
+
357
+ ```tsx
358
+ // app/login/page.tsx
359
+ 'use client'
360
+ import { loginAction } from '../actions'
361
+
362
+ export default function LoginPage() {
363
+ async function handleSubmit(formData: FormData) {
364
+ const result = await loginAction(formData)
365
+ if (result.success) {
366
+ window.location.href = '/dashboard' // full page load
367
+ }
368
+ }
369
+
370
+ return <form action={handleSubmit}>...</form>
355
371
  }
356
372
  ```
357
373
 
@@ -368,7 +384,7 @@ export default function Dashboard() {
368
384
  }
369
385
  ```
370
386
 
371
- Next.js Server Actions handle `Set-Cookie` headers automatically, so server-side `login()`/`logout()` work well with `redirect()`.
387
+ Use `window.location.href` instead of Next.js `redirect()` after server-side auth mutations. Next.js `redirect()` triggers a soft navigation via the Router, which may not include the newly-set auth cookie. A full page load ensures the cookie is sent and the server sees the updated auth state. Reading auth state with `getUser()` in Server Components works normally, and `redirect()` is fine for auth gates (where no cookie was just set).
372
388
 
373
389
  ### Remix
374
390
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/identity",
3
- "version": "0.1.1-alpha.18",
3
+ "version": "0.1.1-alpha.19",
4
4
  "type": "module",
5
5
  "description": "Add authentication to your Netlify site with a few lines of code",
6
6
  "main": "./dist/index.cjs",