How to use this example in your own projects?

1. Clone the code.

# Get the project.
git clone git@github.com:michaelcuneo/sveltekit-sst-auth.git
cd sveltekit-sst-auth
npm install
npx sst dev

# In another terminal.
cd packages/sveltekit
npm run dev

2. Run the following for each variable that you want to use based on what login type you want activated.

npx sst secrets set [environment-variable] ["value"]

If you want to run MagicLinks auth, add email secrets for the NODE_MAILER CONFIG If you want to run Federated Identities, add secrets for the GOOGLE, and/or META CONFIG.

Example

for the default stage you're in

npx sst secrets set EMAIL_SERVICE "Gmail"
or, for staged environment variables.
npx sst secrets --stage production set EMAIL_SERVICE "Gmail"

List of all secrets

# NODE_MAILER CONFIG FOR MAGIC LINKS
EMAIL_SERVICE="Gmail"
EMAIL_HOST="smtp.gmail.com"
EMAIL_PORT="465"
EMAIL_USER="user@gmail.com"
EMAIL_APP_PASS="abcd efgh ijkl mnop"
# GOOGLE CONFIG FOR GOOGLE FEDERATED IDENTITY
GOOGLE_CLIENT_ID="#####-#######.apps.googleusercontent.com"
# META CONFIG FOR META FEDERATED IDENTITY
FACEBOOK_APP_ID="123456789101212131"
FACEBOOK_SECRET="abcd efgh ijkl mnop"
# GITHUB CONFIG FOR GITHUB FEDERATED IDENTITY
GITHUB_CLIENT_ID="123456789"
GITHUB_CLIENT_SECRET="abcd efgh ijkl mnop"

List of all parameters - these are not secret, they are hard coded in stacks/SSTAuthStack.ts

PROJECT_NAME="SvelteKit SST Auth"
DEV_DOMAIN_NAME="https://localhost:3000"
PROD_DOMAIN_NAME="https://skits.michaelcuneo.com.au"
HOSTED_ZONE_NAME="michaelcuneo.com.au"
API_DOMAIN_NAME="https://skitsapi.michaelcuneo.com.au"
VERSION="1.0.0"

3. Modify the configs

sst.config.ts and stacks/SSTAuthStack.ts to suit your own purposes.

The things you might want to change here are the region, the project name, the stages, edge, etc

4. Profit

Speaking of profit, if you really really like what I've done here and it has helped you in some way towards making a better authentication service for your projects, feel free to donate to my beer and coffee allowance, here's my paypal

Get the code from GitHub, Join my #Slack for questions.