Skip to content

Command-line utility to manage your Vercel project redirects. Doubles as a url shortener.

License

Notifications You must be signed in to change notification settings

codfish/vercel-redirects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vercel-redirects

Command-line utility to manage your Vercel project redirects. Doubles as a url shortener.

version downloads GitHub Workflow Status MIT License PRs Welcome Semantic Release Commitizen friendly

vercel-redirects example usage

Table of Contents

Installation

This module is distributed via npm which is bundled with node. It can be installed as one of your project's devDependencies and used via an npm script.

npm install --save-dev vercel-redirects
{
  "scripts": {
    "shorten": "vercel-redirects"
  }
}

You can then then run npm run shorten <destination-url>.

You can also install and run this globally.

npm install -g vercel-redirects

Or run it through npx.

npx vercel-redirects https://url.to.redirect.to.com

Usage

Use the cli directly from your command line or as an npm script.

Usage: vercel-redirects [options] [command]

Options:
  -v, --version                         Output the current version.
  -h, --help                            display help for command

Commands:
  add [options] <destination> [source]  Add a new redirect. Short url is created for you if you dont provide a source.
  help [command]                        display help for command

Add

Usage: vercel-redirects add [options] <destination> [source]

Add a new redirect. Short url is created for you if you dont provide a source.

Options:
  -c, --status-code <code>  HTTP status code. Must be a value between 301-308.
  -h, --help                display help for command

Note: This is the default command, so it can be left out if you prefer.

Simple

vercel-redirects add /destination-url /source-url
vercel-redirects /destination-url /source-url
vercel-redirects -c 302 /destination-url /source-url
vercel-redirects --status-code 302 /destination-url /source-url
vercel-redirects https://codfish.io /source-url

Url Shortener

vercel-redirects add /destination-url
vercel-redirects /destination-url
vercel-redirects https://codfish.io
vercel-redirects -c 302 https://codfish.io
vercel-redirects --status-code 302 https://codfish.io

Configuration

Add configuration in the following ways (in order of precedence):

  1. A vercel-redirects object in your package.json.
  2. A .vercelredirectsrc.json file to the root of your project.
  3. A .vercelredirectsrc file to the root of your project.

package.json example:

{
  "vercel-redirects": {
    "autoPush": true
  }
}

.vercelredirectsrc.json and .vercelredirectsrc example:

{
  "autoPush": true
}
Variable Type Default Description
autoPush boolean false Automatically commit and push, effectively deploying whenever changes are made.

Inspiration

I had originally created a URL shortener, codfi.sh, for a project I built as a part of a General Assembly course. For a number of reasons, this project was kind of a pain to maintain for me over the years.

I stumbled upon Kent C. Dodd's netlify-shortner & his url shortener app tutorial, and was motivated to create my own and migrate my short url domain, codfi.sh to use that instead.

However, I'm a huge fan of Vercel (formally Now) and that's what I personally use for all my serverless apps. This cli utility was built to help facilitate the creation of redirects & short urls for Vercel projects, very much in the same vein as netlify-shortener.

LICENSE

MIT

About

Command-line utility to manage your Vercel project redirects. Doubles as a url shortener.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published