How to Install Umami on Vercel and Supabase (100% Working)
Monday, Dec 9, 2024
I used to use Google Analytics (GA), but website performance became slow, and the data wasn’t 100% safe. Umami became an alternative because it’s self-hosted, doesn’t affect website speed, and its features are just as complete.
In this tutorial, I’ll guide you on how to install Umami with Vercel (hosting) and Supabase (database) - 100% free!
What is Umami?
Umami is web analytics that is:
- ✅ Open source
- ✅ Privacy-friendly (no cookies)
- ✅ Lightweight (~2KB script)
- ✅ Self-hosted
- ✅ Simple and clean UI
Prerequisites
- GitHub account
- Vercel account (free)
- Supabase account (free)
Step 1: Setup Database in Supabase
1.1 Create New Project
- Open supabase.com
- Login with GitHub
- Click “New Project”
- Fill in details:
- Name:
umami-analytics - Database Password: (generate strong password, save it!)
- Region: choose the closest one
- Name:
- Click “Create new project”
1.2 Get Connection String
- Go to Settings → Database
- Scroll to Connection string
- Select URI tab
- Copy connection string
- Replace
[YOUR-PASSWORD]with the password you created
Format:
postgresql://postgres.[project-id]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres
Step 2: Fork Umami Repository
- Open github.com/umami-software/umami
- Click Fork
- Keep default settings
- Click Create fork
Step 3: Deploy to Vercel
3.1 Import Project
- Open vercel.com
- Click Add New → Project
- Import the forked
umamirepository - Click Import
3.2 Configure Environment Variables
Before deploying, add environment variables:
| Key | Value |
|---|---|
DATABASE_URL | Connection string from Supabase |
HASH_SALT | Random string (can generate at random.org) |
3.3 Deploy
- Click Deploy
- Wait for build process (about 2-3 minutes)
- After completion, click Visit to open dashboard
Step 4: Login to Umami
Default credentials:
- Username:
admin - Password:
umami
⚠️ Important: Change password immediately after login!
- Login with default credentials
- Click Settings → Profile
- Change password
Step 5: Add Website
- Click Settings → Websites
- Click Add website
- Fill in:
- Name: Your website name
- Domain: Website domain (without https://)
- Click Save
Step 6: Install Tracking Script
- On Websites page, click Edit on the newly created website
- Click Tracking code tab
- Copy the script
<script
async
src="https://your-umami-domain.vercel.app/script.js"
data-website-id="your-website-id"
></script>
For Next.js
In app/layout.tsx:
import Script from 'next/script'
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<Script
async
src="https://your-umami.vercel.app/script.js"
data-website-id="your-website-id"
/>
</body>
</html>
)
}
For Astro
In src/layouts/Layout.astro:
<script
async
src="https://your-umami.vercel.app/script.js"
data-website-id="your-website-id"
></script>
Step 7: Verify
- Open your website
- Open Umami dashboard
- You should see 1 visitor (you!)
Troubleshooting
Data not appearing?
- Make sure script is installed correctly
- Check browser Console for errors
- Make sure domain in Umami matches website domain
Error during deploy?
- Make sure
DATABASE_URLformat is correct - Make sure password doesn’t have special characters that need escaping
Conclusion
With Umami, you can have analytics that is:
- Free (Vercel + Supabase free tier)
- Privacy-friendly
- Fast and lightweight
- Self-hosted
Congratulations! You now have your own analytics 🎉
Have questions? Reach out on Twitter @nayakayp!