Skip to content

Commit 5457479

Browse files
[BUG-1919] experimental app router updates to next 15 and react 19 (#1994)
* fix(experimental-app-router): Resolve onLogin issue on Vercel deployment (#1919) * fix(experimental-app-router): Resolve onLogin issue on Vercel deployment - adding one more eslint addition (#1919) * fix(experimental-app-router): Resolve onLogin issue on Vercel deployment - updating example repo (#1919) * adding changset * fix(experimental-app-router): Resolve onLogin issue on Vercel deployment - Adding use server on logout action(#1919) * Testing on example repo * Testing on example repo * (@faustwp/experimental-app-router) Updating example next 15 errors related to awaiting params (1919) * (@faustwp/experimental-app-router) Updating example next 15 errors related to awaiting params (1919) * (@faustwp/experimental-app-router) Updating changeset (1919) * [bug-1919-experimental-app-router] Bumping down next version on example
1 parent dc2b753 commit 5457479

File tree

16 files changed

+3528
-42
lines changed

16 files changed

+3528
-42
lines changed

.changeset/three-singers-roll.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
'@faustwp/experimental-app-router': minor
3+
---
4+
5+
---
6+
7+
## '@faustwp/experimental-app-router': minor
8+
9+
Update @faustwp/experimental-app-router to account for next 15 changes to cookies and update NextResponse import
10+
11+
Notable changes:
12+
13+
- Adding await to all cookies requests as per Next documentation: https://nextjs.org/docs/app/api-reference/functions/cookies
14+
15+
```
16+
import { cookies } from 'next/headers'
17+
18+
export default async function Page() {
19+
const cookieStore = await cookies()
20+
const theme = cookieStore.get('theme')
21+
return '...'
22+
}
23+
```
24+
25+
- Files changed:
26+
27+
- packages/experimental-app-router/src/server-actions/logoutAction.ts
28+
- packages/experimental-app-router/src/server-actions/utils/setRefreshToken.ts
29+
- packages/experimental-app-router/src/server/auth/fetchTokens.ts
30+
- packages/experimental-app-router/src/server/routeHandler/tokenHandler.ts
31+
32+
- Updated Next App Router example to use latest next version and React 19 RC.
33+
- Updated Example Login form using React 19s useActionState
34+
- Updated Awaiting of params for Next 15
35+
- Files Changed:
36+
- examples/next/app-router/app/login/page.tsx
37+
- examples/next/app-router/package.json
38+
- examples/next/app-router/[slug]hasPreviewProps.ts (made async)
39+
- examples/next/app-router/[slug]page.tsx
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
export function hasPreviewProps(props: any) {
2-
return props?.searchParams?.preview === 'true' && !!props?.searchParams?.p;
1+
export async function hasPreviewProps(props: any) {
2+
const { searchParams } = await props;
3+
const { preview, p } = await searchParams;
4+
5+
return preview === 'true' && !!p;
36
}

examples/next/app-router/app/[slug]/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { hasPreviewProps } from './hasPreviewProps';
44
import { PleaseLogin } from '@/components/please-login';
55

66
export default async function Page(props) {
7-
const isPreview = hasPreviewProps(props);
8-
const id = isPreview ? props.searchParams.p : props.params.slug;
7+
const { searchParams, params } = await props;
8+
const { slug } = await params;
9+
const { p } = await searchParams;
10+
const isPreview = await hasPreviewProps(props);
11+
const id = isPreview ? p : slug;
912

1013
let client = isPreview ? await getAuthClient() : await getClient();
1114

examples/next/app-router/app/login/page.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
'use client';
22

3-
import { useFormState, useFormStatus } from 'react-dom';
43
import { loginAction } from './action';
5-
6-
function SubmitButton() {
7-
const status = useFormStatus();
8-
return (
9-
<button disabled={status.pending}>
10-
{status.pending ? 'Loading...' : 'Login'}
11-
</button>
12-
);
13-
}
4+
import { useActionState } from 'react';
145

156
export default function Page() {
16-
const [state, formAction] = useFormState(loginAction, {});
7+
const [state, formAction, isPending] = useActionState(loginAction, {});
178

189
return (
1910
<>
@@ -30,7 +21,9 @@ export default function Page() {
3021
<input type="password" name="password" />
3122
</fieldset>
3223

33-
<SubmitButton />
24+
<button disabled={isPending}>
25+
{isPending ? 'Loading...' : 'Login'}
26+
</button>
3427

3528
{state.error && (
3629
<p dangerouslySetInnerHTML={{ __html: state.error }}></p>

examples/next/app-router/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

0 commit comments

Comments
 (0)