Generator to create your own personal url shortener to deploy to Vercel (formerly Zeit Now).
These aren't prerequisites but before you're able to actually deploy your url shortener you should:
- Create a Vercel account.
- Set up Vercel GitHub Integration. This way Vercel deploys automatically for you.
- Buy, migrate or simply point a domain you already own to Vercel's dns.
You don't technically need to have a domain. By default your new project in Vercel will be deployed
with a domain like https://my-url-shortener.vercel.app
, and your redirects will work just fine.
However part of the glory of url shorteners is that they create short urls that are easy to type
and remember!
npm install -g yo generator-vercel-shortener
yo vercel-shortener
By default it will look to generate in your current working directory. If that's not what you want, then specify the directory in the call or create a new directory to run the generator in.
yo vercel-shortener [<project-directory>]
or...
mkdir <project-directory>
cd <project-directory>
yo vercel-shortener
Next steps after generating:
- Create a repository for your url shortener, https://github.com/new.
- Run
git remote add origin <repo_url>
. - Run
git push origin main
. - Run
git branch -u origin/main
. - Run
vercel
to setup & deploy your project to Vercel. - Add redirects:
- Run
shorten <destination> [<source>]
. The generator will expose a globally available script for you. Run this from anywhere in your terminal. See vercel-redirects for the full cli documentation. - Run
npm run shorten <destination> [<source>]
from the root of the project. - Add them in
vercel.json
manually. You'll need to commit and push them yourself.
- Run
For example:
shorten https://gist.github.com/codfish/91ef26f3a56a5c5ca0912aa8c0c5c020 /linting
And in about ~5 seconds I can hit codfi.sh/linting and it will redirect for me.
codfi.sh
- My own personal url shortener, using the same configuration as a project built with this generator.vercel-redirects
- Command-line utility to manage your Vercel project redirects.netlify-shortener
- Your own free URL shortener with Netlify (different serverless platform).