{"id":13493193,"url":"https://github.com/kentcdodds/netlify-shortener","last_synced_at":"2025-05-14T14:07:26.471Z","repository":{"id":52944248,"uuid":"160779267","full_name":"kentcdodds/netlify-shortener","owner":"kentcdodds","description":"Your own free URL shortener with Netlify","archived":false,"fork":false,"pushed_at":"2024-11-19T01:26:02.000Z","size":55,"stargazers_count":798,"open_issues_count":2,"forks_count":81,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-11T20:44:11.498Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=HL6paXyx6hM\u0026list=PLV5CVI1eNcJgCrPH_e6d57KRUTiDZgs0u","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kentcdodds.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-07T06:09:57.000Z","updated_at":"2025-03-30T00:45:14.000Z","dependencies_parsed_at":"2024-12-19T11:01:22.136Z","dependency_job_id":"7bf74d07-c619-44d7-9040-536ca313a4f8","html_url":"https://github.com/kentcdodds/netlify-shortener","commit_stats":{"total_commits":39,"total_committers":20,"mean_commits":1.95,"dds":0.7948717948717949,"last_synced_commit":"f420a4df98f7af87f7169a02c6213c9c75c121e3"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fnetlify-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fnetlify-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fnetlify-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentcdodds%2Fnetlify-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kentcdodds","download_url":"https://codeload.github.com/kentcdodds/netlify-shortener/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159194,"owners_count":22024558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:13.085Z","updated_at":"2025-05-14T14:07:26.452Z","avatar_url":"https://github.com/kentcdodds.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1\u003enetlify-shortener\u003c/h1\u003e\n\n\u003cp\u003eUses netlify's redirect functionality to make a personal URL shortener. Works beautifully :)\u003c/p\u003e\n\u003c/div\u003e\n\n---\n\n\u003c!-- prettier-ignore-start --\u003e\n[![Build Status][build-badge]][build]\n[![Code Coverage][coverage-badge]][coverage]\n[![version][version-badge]][package]\n[![downloads][downloads-badge]][npmtrends]\n[![MIT License][license-badge]][license]\n[![All Contributors][all-contributors-badge]](#contributors-)\n[![PRs Welcome][prs-badge]][prs]\n[![Code of Conduct][coc-badge]][coc]\n\u003c!-- prettier-ignore-end --\u003e\n\n## The problem\n\nYou want a URL shortener for your custom domain and you want an easy way to\ncreate and update URLs but you don't want to pay hundreds of dollars a year.\n\n## This solution\n\nThis relies on [Netlify's](https://www.netlify.com)\n[`_redirects`](https://www.netlify.com/docs/redirects/) file for building a\nsuper simple URL shortener where the URLs are managed on GitHub and Netlify\nhandles the redirecting for you.\n\n## Table of Contents\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Shell Function](#shell-function)\n  - [Shell Agnostic](#shell-agnostic)\n  - [Bash](#bash)\n- [Inspiration](#inspiration)\n- [Other Solutions](#other-solutions)\n- [Issues](#issues)\n  - [🐛 Bugs](#-bugs)\n  - [💡 Feature Requests](#-feature-requests)\n- [Contributors ✨](#contributors-)\n- [LICENSE](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\nThis module is distributed via [npm][npm] which is bundled with [node][node] and\nshould be installed as one of your project's `dependencies`:\n\n```\nnpm install --save netlify-shortener\n```\n\n## Usage\n\n- [Watch a demo](https://www.youtube.com/watch?v=HL6paXyx6hM\u0026list=PLV5CVI1eNcJgCrPH_e6d57KRUTiDZgs0u)\n- [View the example repo](https://github.com/kentcdodds/netlify-shortener-example)\n\nYour project should have a `_redirects` file that looks like this:\n\n```\n/example http://example.com\n\n# fallback\n/*       https://your-website.com\n```\n\nThis module exposes a binary that you should use in your `package.json` scripts.\nYou also need to add a `homepage` to your `package.json`:\n\n```json\n{\n  \"homepage\": \"https://jsair.io\",\n  \"scripts\": {\n    \"shorten\": \"netlify-shortener\"\n  }\n}\n```\n\nThen you can run:\n\n```\nnpm run shorten # simply formats your _redirects file\nnpm run shorten https://yahoo.com # generates a short code and adds it for you\nnpm run shorten https://github.com gh # adds gh as a short URL for you\n```\n\nThe `netlify-shortener` does a few things:\n\n1. generates a short code if one is not provided\n2. validates your URL is a real URL\n3. adds the URL to the top of `_redirects`\n4. runs a git commit and push (this will trigger netlify to deploy your new\n   redirect)\n5. Copies the short URL to your clipboard\n\nNetlify's deploys are normally fast enough that the new URL should be deployed\nby the time you've shared it to someone.\n\n\u003ca name=\"bash-function\"\u003e\u003c/a\u003e\n\n## Shell Function\n\nIf you want to be able to run this anywhere in the terminal, you can try making\na custom function for your shell.\n\n### Shell Agnostic\n\n1. Add the following [executable definition][npm-bin] to your `package.json`:\n   ```json\n   {\"bin\": {\"shorten\": \"cli.js\"}}\n   ```\n2. Create the `cli.js` file:\n   ```js\n   #!/usr/bin/env node\n   require('netlify-shortener')\n   ```\n3. From your project directory, run the following to register the command\n   globally:\n   ```sh\n   npm link\n   ```\n\n## ScriptKit\n\nYou can use [this script](https://github.com/johnlindquist/kit/discussions/295#discussion-3383989)\nwith [ScriptKit](https://www.scriptkit.com/) which integrates with netlify-shortener as well.\n\n## Inspiration\n\nURL shorteners for custom domains and custom short codes are insanely expensive.\nHiveam.com was the best price-wise, but the price went up and it's super\nexpensive as well.\n\n## Other Solutions\n\n- [netlify-shortener-sh](https://github.com/caarlos0/netlify-shortener-sh):\n  plain shell script version\n\nIf you know more alternatives, please [make a pull request][prs] and add it\nhere!\n\n## Issues\n\n_Looking to contribute? Look for the [Good First Issue][good-first-issue]\nlabel._\n\n### 🐛 Bugs\n\nPlease file an issue for bugs, missing documentation, or unexpected behavior.\n\n[**See Bugs**][bugs]\n\n### 💡 Feature Requests\n\nPlease file an issue to suggest new features. Vote on feature requests by adding\na 👍. This helps maintainers prioritize what to work on.\n\n[**See Feature Requests**][requests]\n\n## Contributors ✨\n\nThanks goes to these people ([emoji key][emojis]):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://kentcdodds.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1500684?v=3?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKent C. Dodds\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=kentcdodds\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=kentcdodds\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#infra-kentcdodds\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e \u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=kentcdodds\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/CarlRosell\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/2036823?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eCarl Rosell\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-CarlRosell\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://hawksworx.com\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/5865?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePhil Hawksworth\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-philhawksworth\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://mattferderer.com\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/2480667?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMatt Ferderer\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=mattferderer\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://j-f1.github.io\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/25517624?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJed Fox\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#example-j-f1\" title=\"Examples\"\u003e💡\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://edm00se.codes/\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/622118?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eEric McCormick\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=edm00se\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://www.prestonlamb.com\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/2006222?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePreston Lamb\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=pjlamb12\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://ddbeck.com/\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/64103?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDaniel D. Beck\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=ddbeck\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://stackshare.io/jdorfman/decisions\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/398230?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJustin Dorfman\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#fundingFinding-jdorfman\" title=\"Funding Finding\"\u003e🔍\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://jarv.is\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1703673?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJake Jarvis\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=jakejarvis\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://michaeldeboey.be\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/6643991?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMichaël De Boey\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=MichaelDeBoey\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://oisin.io\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/5693967?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eOisín Quinn\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=oisinq\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=oisinq\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/SebJones\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/13268343?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSebJones\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=SebJones\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://gabinaureche.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/2291025?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eGabin Aureche\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=Zhouzi\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=Zhouzi\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://twitter.com/nat0n\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/444538?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAnton Andreasson\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=naton\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://www.marcuslyons.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/10541922?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMarcus Lyons\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kentcdodds/netlify-shortener/commits?author=marcuslyons\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors][all-contributors] specification.\nContributions of any kind welcome!\n\n## LICENSE\n\nMIT\n\n\u003c!-- prettier-ignore-start --\u003e\n[npm]: https://www.npmjs.com\n[node]: https://nodejs.org\n[build-badge]: https://img.shields.io/github/workflow/status/kentcdodds/netlify-shortener/validate?logo=github\u0026style=flat-square\n[build]: https://github.com/kentcdodds/netlify-shortener/actions?query=workflow%3Avalidate\n[coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/netlify-shortener.svg?style=flat-square\n[coverage]: https://codecov.io/github/kentcdodds/netlify-shortener\n[version-badge]: https://img.shields.io/npm/v/netlify-shortener.svg?style=flat-square\n[package]: https://www.npmjs.com/package/netlify-shortener\n[downloads-badge]: https://img.shields.io/npm/dm/netlify-shortener.svg?style=flat-square\n[npmtrends]: http://www.npmtrends.com/netlify-shortener\n[license-badge]: https://img.shields.io/npm/l/netlify-shortener.svg?style=flat-square\n[license]: https://github.com/kentcdodds/netlify-shortener/blob/main/LICENSE\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n[prs]: http://makeapullrequest.com\n[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square\n[coc]: https://github.com/kentcdodds/netlify-shortener/blob/main/CODE_OF_CONDUCT.md\n[emojis]: https://github.com/all-contributors/all-contributors#emoji-key\n[all-contributors]: https://github.com/all-contributors/all-contributors\n[all-contributors-badge]: https://img.shields.io/github/all-contributors/kentcdodds/netlify-shortener?color=orange\u0026style=flat-square\n[bugs]: https://github.com/kentcdodds/netlify-shortener/issues?utf8=%E2%9C%93\u0026q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug\n[requests]: https://github.com/kentcdodds/netlify-shortener/issues?utf8=%E2%9C%93\u0026q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement\n[good-first-issue]: https://github.com/kentcdodds/netlify-shortener/issues?utf8=%E2%9C%93\u0026q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement+label%3A%22good+first+issue%22\n\n[npm-bin]: https://docs.npmjs.com/files/package.json#bin\n\u003c!-- prettier-ignore-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentcdodds%2Fnetlify-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkentcdodds%2Fnetlify-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentcdodds%2Fnetlify-shortener/lists"}