DEV Community

Cover image for Self-Host Your Own URL Shortener with Zero Database Setup
Wolfgang Rathgeb
Wolfgang Rathgeb

Posted on

2

Self-Host Your Own URL Shortener with Zero Database Setup

Self-hosting shouldn't require a PhD in DevOps. After trying various URL shorteners that demanded complex database setups and endless configuration files, I built shrtn.io – a lightweight, self-hosted URL shortener that actually respects your time.

Why Another URL Shortener?

Most self-hosted solutions require MySQL/PostgreSQL setup, complex configurations, and heavy resource usage. shrtn.io takes a different approach:

  • SQLite by default – No database server required
  • SvelteKit-powered – Lightning fast and resource-efficient
  • Single Docker container – Deploy in seconds
  • Flexible deployment – Docker, Cloudflare Workers, or traditional hosting

Key Features That Actually Matter

Privacy-First Design

  • Flexible access control: public access, private (login required), or public-only
  • Restrict access by email addresses or domains
  • Disable public interface for complete privacy
  • Hide user login when running in public-only mode
  • Your data stays on your server

Smart Link Protection

  • Automatic DNS verification
  • Blocks internal/private IP addresses by default
  • Configurable security policies
  • Allow internal links via feature flag

Developer-Friendly

  • Multiple database options: SQLite, libSQL, Turso, Cloudflare D1
  • Custom domain support
  • Configurable TTL limits
  • Clean API design

Getting Started (The Easy Way)

Docker (Recommended):

docker run -d \
   -p 3001:3001 \
   --name my-shrtn \
   -v ~/shrtn-data:/data \
   -e ORIGIN=https://url.example.com \
   -e PUBLIC_INSTANCE_MODE=PUBLIC_ONLY
   cordlesswool/shrtn
Enter fullscreen mode Exit fullscreen mode

Cloudflare Workers:
Deploy directly to Cloudflare's edge network with D1 database integration.

That's it. No database installation, no complex environment files, no headaches.

Setup a private instance

Check out the setup guide at https://shrtn.io/setup to configure a private instance. All you need to do is set PUBLIC_INSTANCE_MODE=PRIVATE and configure an email provider.

Why Self-Host Your URL Shortener?

  • Control your data – No third-party analytics harvesting
  • Custom domains – Perfect branding for your links
  • No rate limits – Create as many links as you need
  • Privacy compliance – GDPR/CCPA friendly by design
  • No vendor lock-in – Export your data anytime

What's Next?

shrtn.io started as a side project but has grown to over 45 stars on GitHub (and counting!). The focus remains on simplicity and developer experience – features that solve real problems without bloat.


Try shrtn.io today: https://shrtn.io

GitHub: Check out the setup guide and contribute to the project

Self-hosting should be simple. URL shortening should be private. shrtn.io delivers both.

Top comments (2)

Collapse
 
youngfra profile image
Fraser Young

This looks like a great project, but doesn’t using SQLite or D1 still count as using a database? I wonder if a true file-based solution (like a flat file) would be even simpler for really small use cases. Would love to hear your thoughts!

Collapse
 
cordlesswool profile image
Wolfgang Rathgeb

True, at least SQLite is a database, but at least any kind of storage would be a kind of database. The most important thing is that you do not have to set one up and do not have to care about it.

If you store data in other formats, you can just lose benefits. What you mean by true file-based would be something like JSON or YAML? It will lose all kinds of optimizations and features. So the performance will be much slower until you build your own optimizations.

At least a SQLite Database is only a file.

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay