Skip to content

Commit

Permalink
Add example where next-auth works if local
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevers committed May 11, 2023
1 parent 421be2d commit ca99b9e
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 95 deletions.
161 changes: 161 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
},
"devDependencies": {
"@types/cookie": "^0.5.1"
}
}
2 changes: 1 addition & 1 deletion src/app/issue1/ClientExampleEmbeddedServer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

interface Props {
action: (message: string) => Promise<string>;
action: (message: string) => Promise<any>;
}

export default function ClientExampleEmbeddedServer(props: Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/issue1/ServerExample.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server';

import { getServerSession } from 'next-auth/next';
import { getSession } from '@/util/session';

export default async function ServerExample(message: string) {
return await getServerSession({});
return await getSession();
}
4 changes: 2 additions & 2 deletions src/app/issue1/ServerExample2.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server';

import { getServerSession } from 'next-auth/next';
import { getSession } from '@/util/session';

export default async function ServerExample2(message: string) {
return await getServerSession({});
return await getSession();
}
2 changes: 1 addition & 1 deletion src/app/issue2/ClientExampleEmbeddedServer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

interface Props {
action: (message: string) => Promise<string>;
action: (message: string) => Promise<any>;
}

export default function ClientExampleEmbeddedServer(props: Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/issue2/SharedServerExample.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server';

import { getServerSession } from 'next-auth/next';
import { getSession } from '@/util/session';

export default async function ServerExample(message: string) {
return await getServerSession({});
return await getSession();
}
11 changes: 11 additions & 0 deletions src/app/local/ClientExampleEmbeddedServer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client';

interface Props {
action: (message: string) => Promise<any>;
}

export default function ClientExampleEmbeddedServer(props: Props) {
return (
<button onClick={async () => console.log('ClientExampleEmbeddedServer', await props.action('hi'))}>client passed with shared server action: I will log</button>
)
}
9 changes: 9 additions & 0 deletions src/app/local/ClientImportsOwnServer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client';

import ServerExample from "./SharedServerExample";

export default function ClientImportsOwnServer() {
return (
<button onClick={async () => console.log('ClientImportsOwnServer', await ServerExample('hi'))}>client importing shared server action: I will log</button>
)
}
7 changes: 7 additions & 0 deletions src/app/local/SharedServerExample.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use server';

import { __unstable__getSession } from "@/util/session";

export default async function ServerExample(message: string) {
return await __unstable__getSession();
}
12 changes: 12 additions & 0 deletions src/app/local/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ClientExampleEmbeddedServer from "./ClientExampleEmbeddedServer"
import ClientImportsOwnServer from "./ClientImportsOwnServer";
import ServerExample from "./SharedServerExample"

export default function Page() {
return (
<div>
<ClientExampleEmbeddedServer action={ServerExample}/>
<ClientImportsOwnServer />
</div>
)
}
Loading

0 comments on commit ca99b9e

Please sign in to comment.