Overview
This repository is a demo for building an AuthJS.dev authenticated site with SvelteKit and deployment on Cloudflare Pages using a D1(Alpha) database adapter for the authjs.dev user and session store. It demonstrates this using a GitHub OAuth application as the authentication provider.
Features
- Building an authenticated site with SvelteKit
- Deployment on Cloudflare Pages
- Usage of D1(Alpha) database adapter for user and session store
- GitHub OAuth authentication integration
- Demostration of AuthJS.dev
Installation
- Clone or Fork and Clone this project to your local machine.
- Create a GitHub OAuth App for local development. Use the following details:
- Homepage Url: http://127.0.0.1:8788
- Authorization Callback URL: http://127.0.0.1:8788/auth/callback/github
- Generate a secret and keep it and the client id somewhere temporarily, you will need it in the next steps
- Click Register and then click Update Application
- Rename the
.dev.vars.examplefile to.dev.vars. - Fill in the client id and secret from the previous step in your
.dev.varsfile. This file is in.gitignore. - Follow the instructions in the file to generate an
AUTH_SECRET. - Test locally by running the following commands in your terminal:
npm installnpm run buildnpm run wrangle
- In a separate terminal session, run
npx vite build -wto have vite auto build when it sees source changes. - Open a browser to http://127.0.0.1:8788 or whatever port shows up in the terminal output from
npm run wrangle.
Summary
This repository provides a demo of building an AuthJS.dev authenticated site with SvelteKit and deploying it on Cloudflare Pages using a D1(Alpha) database adapter for the AuthJS.dev user and session store. It includes integration with GitHub OAuth for authentication. The installation guide provides step-by-step instructions on setting up the project for local development and testing.