https://github.com/theotterlord/starlight-auth
Starlight + Auth.js template
https://github.com/theotterlord/starlight-auth
astro authjs starlight
Last synced: 10 days ago
JSON representation
Starlight + Auth.js template
- Host: GitHub
- URL: https://github.com/theotterlord/starlight-auth
- Owner: TheOtterlord
- Created: 2024-04-10T19:00:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-20T19:19:16.000Z (11 months ago)
- Last Synced: 2025-03-27T16:55:55.552Z (28 days ago)
- Topics: astro, authjs, starlight
- Language: TypeScript
- Homepage: https://starlight-auth-development.vercel.app/
- Size: 341 KB
- Stars: 47
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Starlight Starter Kit: Auth
[](https://starlight.astro.build)
```
npm create astro@latest -- --template TheOtterlord/starlight-auth
```[](https://stackblitz.com/github/TheOtterlord/starlight-auth/tree/main/examples/basics)
[](https://codesandbox.io/p/sandbox/github/TheOtterlord/starlight-auth/tree/main/examples/basics)
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FTheOtterlord%2Fstarlight-auth%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)## Setting up Auth
### Authentication
You can customize the available sign-in methods in `auth.config.js`. [Auth.js](https://authjs.dev) supports [e-mail signin](https://authjs.dev/getting-started/authentication/email), traditional [username/password](https://authjs.dev/getting-started/authentication/credentials) auth, and 80+ [OAuth](https://authjs.dev/getting-started/authentication/oauth) providers. This template uses GitHub OAuth as an example.
### Authorization
By default, any authenticated user will be authorized to view your gated content. You can add additional authorization checks to the `isAuthed` function in `src/lib/auth.ts`. If the function returns `true`, a user it authorized to access the page, and vice-versa if `false` is returned. The example logic restricts access to routes defined in `paths` above the `isAuthed` function.
### Environment Variables
You may require different environment variables depending on your authentication method(s). Follow the example given in `.env.example` to create your `.env` file, replacing the `GITHUB` variables with the variables for your auth provider.
## Deploy
In `astro.config.ts`, comment out the `adapter` for the platform you want to deploy to, removing the others. Deploy to your preferred provider, adding the environment variables you've defined.
## Want to learn more?
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).