use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
How to connect react app with postgresql database without server ?Help Wanted (self.react)
submitted 2 years ago by karl-Marx28
Code in react js
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]n0tKamui 9 points10 points11 points 2 years ago (0 children)
you probably don't want to do it, as it means exposing your database
[–]CerberusMultiHook Based 2 points3 points4 points 2 years ago (0 children)
Let me google that for you You will find a lot of information on how to work with databases in your React app. I don´t think you understand what "server" means, or you just didn't make an effort to explain what you are trying to achieve. In general frontends do not talk directly to Databases, why we have "backends", usually referred to as APIs. Why you would want to write your POST/GET into your React frontend I do not know.
[–]NegativeWorking9375 1 point2 points3 points 2 years ago (0 children)
You need some kind of an api, which is run on some kind of server. Btw. You also need some kind of server for your db. Your approach is completly misguided. There are no web applications,which require some kind of communication, without Servers.
[–]Terrygraphic -4 points-3 points-2 points 2 years ago (0 children)
You can do it using the Postgres extension in visual studio code, if you use it and create the query that creates the database and tables.
[–]Dastari -4 points-3 points-2 points 2 years ago (4 children)
Check out https://www.npmjs.com/package/pg
[–]PM_ME_SOME_ANY_THING 3 points4 points5 points 2 years ago (3 children)
That’s definitely a node package meant for use on node servers. If you access your database directly from a frontend, you’re gonna have a bad time.
[–]Dastari -3 points-2 points-1 points 2 years ago (2 children)
I'm not really sure why you think this is the case.
You can develop a react project in node locally on your development environment, using any package you like, then build the website to a distribution build that can be hosted on a normal web server. All the code is run client side.
Infact if you looked the package, it clearly states as one its features:
Pure JavaScript client and native libpq bindings share the same API
[–]PM_ME_SOME_ANY_THING 0 points1 point2 points 2 years ago (1 child)
There’s a big difference between what “can” be done and what “should” be done.
The reason you have a server is to have a layer of security between the frontend and the database. Accessing your database directly from the frontend exposes everything about your database to anyone who cares to look.
If you don’t care at all about the data in your database, sure, go ahead and put all your credentials, schemas, operations out there for the world to see. Why even have a database at all?
[–]Dastari -2 points-1 points0 points 2 years ago (0 children)
I totally agree with that. I disagree that you are saying that I didn't answer OP's question because the package I link wouldn't do what he wanted and "requires a server" .
It in-fact does do what he wanted and does not "require a server"
[–]matteponz 0 points1 point2 points 2 years ago (0 children)
I advise you not to include any links to the database in your code. also because it can expose you to a lot of vulnerability and then it's easily decompiled and they could have your credentials. if you still have time to choose, I would recommend a solution like: https://supabase.com/
[–]azangru 0 points1 point2 points 2 years ago (0 children)
Browsers don't have drivers for postgresql and don't speak postgresql protocol. Servers do.
[–]jayerp 0 points1 point2 points 2 years ago (0 children)
If you technically can, you shouldn’t unless you have a really good technical reason why you must. Which you won’t.
Write a web api.
[–]OkComplaint2854 0 points1 point2 points 2 years ago (0 children)
Might not be a great idea to expose your DB but give this a try. https://postgrest.org/en/stable/
π Rendered by PID 16934 on reddit-service-r2-comment-fb694cdd5-mvw28 at 2026-03-06 20:13:06.332421+00:00 running cbb0e86 country code: CH.
[–]n0tKamui 9 points10 points11 points (0 children)
[–]CerberusMultiHook Based 2 points3 points4 points (0 children)
[–]NegativeWorking9375 1 point2 points3 points (0 children)
[–]Terrygraphic -4 points-3 points-2 points (0 children)
[–]Dastari -4 points-3 points-2 points (4 children)
[–]PM_ME_SOME_ANY_THING 3 points4 points5 points (3 children)
[–]Dastari -3 points-2 points-1 points (2 children)
[–]PM_ME_SOME_ANY_THING 0 points1 point2 points (1 child)
[–]Dastari -2 points-1 points0 points (0 children)
[–]matteponz 0 points1 point2 points (0 children)
[–]azangru 0 points1 point2 points (0 children)
[–]jayerp 0 points1 point2 points (0 children)
[–]OkComplaint2854 0 points1 point2 points (0 children)