ATProto SvelteKit Template#
OAuth already figured out for you, a minimal template with ease of use oauth confidential client and local development. Along with a demo how to use the logged-in client. This is just a starting point, it's up to you to build the application.
Features#
- OAuth client configured from
.envvariablesDEV=trueallows local development, do not need a public url- removing
DEV=trueand settingOAUTH_DOMAINis production and requires a public url like demo.atpoke.xyz - Setting
OAUTH_JWKallows for the confidential client that lasts much longer (forever if you refresh the tokens, 180 for indivudal refresh tokens). Can get a value for it from runningnode ./bin/gen-jwk.js
- Server side sessions and automatic loading of the atproto client from
event.locals.atpAgenton server side components. - Examples on how to create atproto records with pokes or making a Bluesky post
- Examples showing how to use microcosm.blue tooling for an appview like experince without the appview.
- See how many people and who have poked you with constellation
- Find the handles from the did easily with slingshot
Dev Setup#
- Copy .env.example to .env, .env.example is dev settings
pnpm install- May need to run
pnpm approve-buildsfor the build scripts for sqlite pnpm run devorpnpm run dev:loggingwith pino-pretty for pretty logging
If you are running locally on a different port than
5173or something else odd can setOAUTH_DOMAIN.env to the domain and port. Just make sure to use either127.0.0.1or[::1](ipv6) for oauth to work for local development.
Production#
Sign up for Railway with my referral code z49xDi to get $20 in credits, and if you spend anything, I get 15% in credits.
Railway#
- Install the railway cli (directions here)
- Login with
railway login - Create a new project with
railway init, set your project name - Deploy your webapp with
railway up, this will create a new deployment. This will crash on the first run since we still have some changes to make. This is what uploads your code to railway. That is expected since we don't have a volume and our variables yet. railway serviceselect the service you deployed earlier, name is most likely the same as the project name.- Run
railway volume add -m /app_datato create a persistent volume for the sqlite database. - If you do not already have your project dashboard open you can open it with
railway open, this opens it in a web browser. - Click on your service, then Variables. Add the following variables:
OAUTH_DOMAIN- your domain nameOAUTH_JWK- the value fromnode ./bin/gen-jwk.jsDATABASE_URL-/app_data/local.db
- Go to settings and select "Custom Domain" to add your domain name. Follow the directions there
And then to update your project going forward you can run railway up again.
Local server like a VPS#
- Install docker
- Copy .env.example to .env and fill in the variables. Make sure to remove
DEV=true docker-compose up
The docker compose comes with Caddy, if you have another reverse proxy you can remove it from the docker compose and just reverse proxy to port 3000. You may also have to play around with the Caddyfile depending on your setup.