A sleek, simple, and powerful URL shortener powered by Supabase
Integrate the Shortnr API into your apps to create short links and redirects instantly.
Create a short URL.
Request:
POST https://your-domain.com/api/shorten
Content-Type: application/json
{
"longUrl": "https://example.com",
"customSlug": "mycustomslug" // Optional
}
Response:
{
"shortUrl": "your-domain.com/mycustomslug",
"slug": "mycustomslug",
"longUrl": "https://example.com"
}
Error Responses:
400 Bad Request - Missing URL or slug already exists
405 Method Not Allowed
500 Internal Server Error
Short URLs redirect automatically.
Visit: https://your-domain.com/mycustomslug
Redirects to: https://example.com
async function shortenUrl(longUrl, customSlug = '') {
const response = await fetch('https://your-domain.com/api/shorten', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ longUrl, customSlug })
});
const data = await response.json();
if (!response.ok) throw new Error(data.error || 'API error');
return data.shortUrl;
}
// Usage
shortenUrl('https://example.com', 'example')
.then(url => console.log('Short URL:', url))
.catch(err => console.error(err));