SvelteKit on Cloudflare Pages to use Auth.js
scaffold:
$ wrangler whoami, logout, login
github.com, new repo, "oauth2.ara.team" (note the periods)
$ git clone [email protected]:/AraBlocks/oauth2.ara.team.git
but then don't cd into it, instead...
$ yarn create cloudflare --platform=pages
╰ In which directory do you want to create your application? also used as application name
./oauth2-ara-team (note the hyphens)
Need to install the following packages: [email protected]
◇ Which template would you like?
│ SvelteKit minimal
◆ Add type checking with TypeScript?
│ ● No
no additional packages
yarn, correctly picks up yarn 1
no git
yes deploy to cloudflare, got the domain:
https://oauth2-ara-team.pages.dev/
move files and folders from oauth2-ara-team to oauth2.ara.team
edit in .gitignore, LICENSE, and README.md
do first git commit
$ yarn build
$ yarn dev (you also always add "local" in package.json scripts)
$ yarn deploy
files:
.dev.vars - api keys for local development; deployed they come from the cloudflare dashboard
src/auth.js - Auth.js configuration and callback code
src/hooks.server.js - re-exports the handle hook from auth.js
src/routes/+page.svelte - home page component we've edited
and the rest is from SvelteKit:
Everything you need to build a Svelte project, powered by sv
.
If you're seeing this, you've probably already done this step. Congrats!
# create a new project in the current directory
npx sv create
# create a new project in my-app
npx sv create my-app
Once you've created a project and installed dependencies with npm install
(or pnpm install
or yarn
), start a development server:
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
To create a production version of your app:
npm run build
You can preview the production build with npm run preview
.
To deploy your app, you may need to install an adapter for your target environment.