A simple URL shortener service powered by Cloudflare Workers and Turso.
- Create short URLs with random keys
- Create custom short URLs
- Authorization required for creating URLs
- Beautiful UI with dark mode support
- Redirect to default URL when form is disabled
- Modern, responsive interface with TailwindCSS
- ShareX integration support
- Hono - Fast, Lightweight, Web-standards Web Framework
- Turso - Edge-hosted SQLite database
- Cloudflare Workers - Serverless platform
- TailwindCSS - Utility-first CSS framework
-
Clone the repository:
git clone https://github.com/yourusername/shortlink.git cd shortlink
-
Install dependencies:
npm install
-
Create a
.dev.vars
file with your environment variables:WORKERLINKS_SECRET=your_secret TURSO_DB_URL=your_turso_db_url TURSO_DB_AUTH_TOKEN=your_turso_auth_token
-
Start the development server:
npm run dev
-
Install Wrangler CLI:
npm install -g wrangler
-
Configure your secrets in Cloudflare:
npx wrangler secret put WORKERLINKS_SECRET npx wrangler secret put TURSO_DB_URL npx wrangler secret put TURSO_DB_AUTH_TOKEN
-
Deploy to Cloudflare Workers:
npm run deploy
You can use this URL shortener with ShareX for quick sharing. Create a new custom uploader in ShareX with the following configuration:
{
"Version": "16.1.0",
"Name": "Shlink v3 Shortener",
"DestinationType": "URLShortener",
"RequestMethod": "POST",
"RequestURL": "https://skiddle.link/api/links",
"Headers": {
"Authorization": "mysecret",
"Content-Type": "application/json"
},
"Body": "JSON",
"Data": "{\n \"url\": \"{input}\"\n}",
"URL": "{json:shorturl}"
}
To set up:
- Open ShareX
- Go to Destinations > Custom Uploader Settings
- Click "Import" > "From Clipboard"
- Paste the configuration above
- Replace
mysecret
with your actual authorization token - Set as default URL shortener in ShareX settings
curl -X POST https://your-domain.com/api/links \
-H "Content-Type: application/json" \
-H "Authorization: your_secret" \
-d '{"url":"https://example.com"}'
Response:
{
"message": "URL created successfully",
"key": "abc123",
"shorturl": "https://your-domain.com/abc123",
"longurl": "https://example.com"
}
curl -X PUT https://your-domain.com/api/links/custom-path \
-H "Content-Type: application/json" \
-H "Authorization: your_secret" \
-d '{"url":"https://example.com"}'
Response:
{
"message": "URL created successfully",
"key": "custom-path",
"shorturl": "https://your-domain.com/custom-path",
"longurl": "https://example.com"
}
MIT License - see LICENSE for details
Created and maintained by Laurensius Jeffrey