0.8.0 • Published 1 month ago
@auth/solid-start v0.8.0
Getting started
Recommended to use create-jd-app
npm install @auth/solid-start@latest @auth/core@latest
Setting It Up
Generate auth secret, then set it as an environment variable:
AUTH_SECRET=your_auth_secret
On Production
Don't forget to trust the host.
AUTH_TRUST_HOST=true
Creating the api handler
in this example we are using github so make sure to set the following environment variables:
GITHUB_ID=your_github_oauth_id
GITHUB_SECRET=your_github_oauth_secret
// routes/api/auth/[...solidauth].ts
import { SolidAuth, type SolidAuthConfig } from "@auth/solid-start"
import GitHub from "@auth/core/providers/github"
export const authOpts: SolidAuthConfig = {
providers: [
GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
debug: false,
}
export const { GET, POST } = SolidAuth(authOpts)
Signing in and out
import { signIn, signOut } from "@auth/solid-start/client"
const login = () => signIn("github")
const logout = () => signOut()
Getting the current session
import { getSession } from "@auth/solid-start"
import { createServerData$ } from "solid-start/server"
import { authOpts } from "~/routes/api/auth/[...solidauth]"
export const useSession = () => {
return createServerData$(
async (_, { request }) => {
return await getSession(request, authOpts)
},
{ key: () => ["auth_user"] }
)
}
// useSession returns a resource:
const session = useSession()
const loading = session.loading
const user = () => session()?.user
1.0.0
22 days ago
0.8.0
1 month ago
0.7.2
1 month ago
0.7.1
2 months ago
0.7.0
2 months ago
0.6.1
3 months ago
0.6.0
3 months ago
0.5.3
3 months ago
0.5.2
3 months ago
0.5.1
3 months ago
0.5.0
3 months ago
0.4.1
3 months ago
0.4.0
3 months ago
0.3.0
3 months ago
0.2.0
4 months ago
0.1.13
4 months ago
0.1.12
4 months ago
0.1.11
4 months ago
0.1.10
4 months ago
0.1.9
5 months ago
0.1.8
5 months ago
0.1.7
5 months ago
0.1.6
5 months ago
0.1.4
6 months ago
0.1.3
6 months ago
0.1.5
6 months ago
0.1.2
7 months ago
0.1.1
1 year ago
0.1.0
1 year ago