ππ΄ A link shortener powered by Vercel Edge Config.
This is a monorepo with two repositories:
A little while back we made the original puhack.horse, which used Airtable as a source of truth. This worked great for us, but we thought it could be even faster if it didn't have to leave the Edge to get its data.
It turns out it's a lot faster! But we lose Airtable, and we have non-technical people on our team who want to be able to super easily edit routesβso the dash repo is an admin dashboard that allows for super easy editing of routes using the SWR Mutation API.
- Create a GitHub OAuth app (Settings β> Developer Settings). Set the callback URL to
YOUR_DOMAIN/api/auth/callback/github. - Create an Edge Config Store on your Vercel Dashboard.
- Clone this repo.
- In
dash/lib/auth.ts, comment out the line withisInOrg()at the bottom, or replace it with your own function. This is used to restrict signup to a group of people (in our case, we only want people in our GitHub org to manage routes). - Deploy the project to Vercel. You'll have to create two projects: one for the
horsefolder and one for thedashfolder. - Set the following environment variables in the
dashproject:NEXT_PUBLIC_HORSE_SECRETEDGE_CONFIG_IDTEAM_IDVERCEL_API_TOKENGITHUB_CLIENT_SECRETGITHUB_CLIENT_IDNEXTAUTH_URLNEXTAUTH_SECRETGH_ACCESS_TOKEN
- Set the following environment variable in the
horseproject:HORSE_SECRET
- Connect the Edge Config Store you created to both projects in their "Edge Config" settings tabs.
- profit!
Note: Edge Config is great but not meant to be used for a serious link shortener. The free plan only allows for 8KB of data, which you'll use up after ~100 routes.
