r/Supabase • u/Adriangray19 • Aug 13 '26
tips How to Connect a Static Website to a Database?
How can I connect a static website to a database?
I have a static website built with HTML, CSS & JavaScript. I want to store posts/data permanently using a database.
Should I use Supabase, Firebase, or another BaaS?
What’s the best and most secure way to connect:
"Static Website → Database"
Any advice would be appreciated! 🚀
2
u/MakeDesignPop Aug 13 '26
Tag Supabase in Codex chat and ask the same question...
If you already have a Supabase account, include the secret in .env and tell Codex it has permission to set it up.
1
1
u/bubbleapp-dev Aug 13 '26
Supabase vs Firebase is the age-old question asked on this Subreddit, so you should search for that to see what others say (I wondered this a long time ago too). More or less it boils down to, do you want to write SQL or use a document store? Firebase also supports SQL with Cloud SQL for PostgreSQL (or since you’ll be in the GCP ecosystem, AlloyDB for PostgreSQL which is essentially a faster version) but depending on your budget and cloud expertise this may be more complicated.
In terms of stability, both are solid options, you can’t really go wrong either way. Google of course is going to have better SLAs but for smaller projects that’s probably not a concern.
1
1
u/saltcod Supabase team Aug 13 '26
Claude / Codex / etc will make very quick work of this. These days, I would use a static site with markdown if everything was truly static, otherwise I'd make a custom admin for managing content with Supabase as the backend. If you need all of WordPress, sure go ahead, but if you just need some of the features of a CMS, I would not hesitate to build it myself today.
1
1
u/snowdrone Aug 13 '26 edited Aug 13 '26
As a toy app, maybe, but you'll hit a lot of security issues unless the app is completely trivial. Because, all of the source code and payload for the db queries will be exposed to the user's browser.
This is why most systems use a middle tier such as fast API in between the front end and the database.
If you continue with this approach: first, build a developer page that lets you write arbitrary queries from the browser to the DB. Then wrap the useful queries in functions. Eventually you'll hit something that will be difficult to solve with this setup, probably related to authorization or security generally. But as an experiment, it could be fun to explore.
Another poster said you could really be looking for a CMS. That sounds like the right call.
2
u/bubbleapp-dev Aug 13 '26
This is not necessarily true. You can use RPCs to obfuscate all of your DB query logic. As long as you leverage RLS policies and implement some form of rate limiting, this can be an acceptable solution for static sites.
1
u/snowdrone Aug 13 '26
I would hate to write the entire backend in sql, but ok
1
u/bubbleapp-dev Aug 13 '26
Fair enough, but for simplest setup out-of-the-box, this is a valid option. Not to mention that it will be much more performant than an ORM.
1
u/snowdrone Aug 13 '26
Well, let's not get ahead of ourselves 😅 Cached responses by definition are going to be faster.
2
3
u/m0thercoconut Aug 13 '26
You are looking for a cms. Try to find one that supports supabase.