diff --git a/.changeset/yellow-foxes-happen.md b/.changeset/yellow-foxes-happen.md new file mode 100644 index 0000000..c27e79e --- /dev/null +++ b/.changeset/yellow-foxes-happen.md @@ -0,0 +1,5 @@ +--- +"create-jd-app": patch +--- + +feat: use latest's auth api diff --git a/src/helpers/packages.ts b/src/helpers/packages.ts index bfd39da..f8407b0 100644 --- a/src/helpers/packages.ts +++ b/src/helpers/packages.ts @@ -11,7 +11,7 @@ const packages = { "@solid-mediakit/prpc": "^1.3.3", "@solid-mediakit/prpc-plugin": "^1.3.4", // authjs - "@solid-mediakit/auth": "^2.1.6", + "@solid-mediakit/auth": "^3.0.0", "@solid-mediakit/auth-plugin": "^1.1.4", "@auth/core": "0.35.0", "@auth/prisma-adapter": "^2.6.0", diff --git a/template/index/with-auth-prpc-tw.tsx b/template/index/with-auth-prpc-tw.tsx index 7737349..b947599 100644 --- a/template/index/with-auth-prpc-tw.tsx +++ b/template/index/with-auth-prpc-tw.tsx @@ -1,6 +1,6 @@ -import { type VoidComponent, Suspense, Show } from "solid-js"; import { A } from "@solidjs/router"; -import { createSession, signOut, signIn } from "@solid-mediakit/auth/client"; +import { useAuth } from "@solid-mediakit/auth/client"; +import { type VoidComponent, Match, Switch } from "solid-js"; import { helloQuery } from "~/server/hello/hello.queries"; const Home: VoidComponent = () => { @@ -38,9 +38,7 @@ const Home: VoidComponent = () => {

{hello.data ?? "Loading pRPC query"}

- - - + @@ -50,30 +48,32 @@ const Home: VoidComponent = () => { export default Home; const AuthShowcase: VoidComponent = () => { - const session = createSession(); + const auth = useAuth(); return (
- Loading...
}> + +
+ + Welcome {auth.session()?.user?.name} + + +
+
+ - } - > - - Welcome {session().data?.user?.name} - - - + + ); }; diff --git a/template/index/with-auth-prpc.tsx b/template/index/with-auth-prpc.tsx index d43bdf2..df597f1 100644 --- a/template/index/with-auth-prpc.tsx +++ b/template/index/with-auth-prpc.tsx @@ -1,7 +1,7 @@ import styles from "./index.module.css"; -import { type VoidComponent, Suspense, Show } from "solid-js"; import { A } from "@solidjs/router"; -import { createSession, signOut, signIn } from "@solid-mediakit/auth/client"; +import { useAuth } from "@solid-mediakit/auth/client"; +import { type VoidComponent, Match, Switch } from "solid-js"; import { helloQuery } from "~/server/hello/hello.queries"; const Home: VoidComponent = () => { @@ -39,9 +39,7 @@ const Home: VoidComponent = () => {

{hello.data ?? "Loading pRPC query"}

- - - + @@ -51,30 +49,30 @@ const Home: VoidComponent = () => { export default Home; const AuthShowcase: VoidComponent = () => { - const session = createSession(); + const auth = useAuth(); return (
- Loading...
}> + + + Welcome {auth.session()?.user?.name} + + + + - } - > - - Welcome {session()?.data?.user?.name} - - - + + ); }; diff --git a/template/index/with-auth-tw.tsx b/template/index/with-auth-tw.tsx index 9b9e390..c50157c 100644 --- a/template/index/with-auth-tw.tsx +++ b/template/index/with-auth-tw.tsx @@ -1,6 +1,6 @@ -import { type VoidComponent, Suspense, Show } from "solid-js"; import { A } from "@solidjs/router"; -import { createSession, signOut, signIn } from "@solid-mediakit/auth/client"; +import { useAuth } from "@solid-mediakit/auth/client"; +import { type VoidComponent, Match, Switch } from "solid-js"; const Home: VoidComponent = () => { return ( @@ -32,9 +32,7 @@ const Home: VoidComponent = () => { - - - + ); @@ -43,30 +41,32 @@ const Home: VoidComponent = () => { export default Home; const AuthShowcase: VoidComponent = () => { - const session = createSession(); + const auth = useAuth(); return (
- Loading...
}> + +
+ + Welcome {auth.session()?.user?.name} + + +
+
+ - } - > - - Welcome {session().data?.user?.name} - - - + + ); }; diff --git a/template/index/with-auth.tsx b/template/index/with-auth.tsx index 37cc61d..5d5ffb0 100644 --- a/template/index/with-auth.tsx +++ b/template/index/with-auth.tsx @@ -1,7 +1,7 @@ import styles from "./index.module.css"; -import { type VoidComponent, Suspense, Show } from "solid-js"; import { A } from "@solidjs/router"; -import { createSession, signOut, signIn } from "@solid-mediakit/auth/client"; +import { useAuth } from "@solid-mediakit/auth/client"; +import { type VoidComponent, Match, Switch } from "solid-js"; const Home: VoidComponent = () => { return ( @@ -33,9 +33,7 @@ const Home: VoidComponent = () => { - - - + ); @@ -44,30 +42,30 @@ const Home: VoidComponent = () => { export default Home; const AuthShowcase: VoidComponent = () => { - const session = createSession(); + const auth = useAuth(); return (
- Loading...
}> + + + Welcome {auth.session()?.user?.name} + + + + - } - > - - Welcome {session()?.data?.user?.name} - - - + + ); };