Calling database with server actions in Solid Start

Hey all, I have a question more about best practices than anything. In the Solid Start docs, under the Server Actions heading, it says the following:
Or even connecting directly to a database. (Take caution, opinions on if this is a good idea are mixed. You should consider separating your backend and frontend).
Or even connecting directly to a database. (Take caution, opinions on if this is a good idea are mixed. You should consider separating your backend and frontend).
My question is why this may be considered a bad idea, especially when it's not frowned upon in createServerData$.
5 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jesseb34r
jesseb34r2y ago
That being said, many people love having an isomorphic app with frontend and backend in the same codebase solid start as a framework is built to support this
alrightsure
alrightsureOP2y ago
I guess I’m aware of the philosophy, I’m more confused on why it would mention it specifically for the actions, but then on the API page it seems to take a stance that it DB calls should be used in the same file: “While we think that using createServerData$ is the best way to write server-side code for data needed by your UI, sometimes you need to expose API routes.” I appreciate the responses! I think I was just worried there was something specifically with the actions that was considered a bad practice, but I am pretty sure I am in the camp that likes the idea of consolidated code in one spot. Will definitely try it out and see how I like it!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
alrightsure
alrightsureOP2y ago
Awesome! I understand the docs (and solid start) are very much in-development so I’m happy even having this much to go off of, I think I was just overthinking the wording.
Want results from more Discord servers?
Add your server