navapbc / template-application-nextjs

Next.js, TypeScript, USWDS, and Storybook template, including CI/CD, for teams at Nava building web applications
Apache License 2.0
10 stars 2 forks source link

Spike: How might we support databases #267

Open sawyerh opened 6 months ago

sawyerh commented 6 months ago

What's the task?

The Next.js template doesn't currently provide any out-of-the-box database support like the Flask template. There's no reason a project couldn't use the Next.js app exclusively though, and there's been at least one instance where we've had to figure out Next.js template DB support at a project level.

The template should provide similar DB support as the Flask template, such as an ORM and DB migrations.

Prior art

The "Flex" initiative used Prisma with the Next.js template. The team ran into several pain points with Prisma, so it may not be the right solution, but there could be aspects that can serve as a useful reference for this ticket. Here are some potential relevant parts:

jcq commented 6 months ago

We'd need to dive in a bit more to see if it can help with the above-mentioned pain points, but I wanted to note that we should look at Drizzle ORM. I haven't yet used it myself, but everyone (online) that I have heard talk about it has said good things. Unlike the Prisma-specific schema declarations, everything is specified in TS code.

It supports a "query" syntax that is abstracted at the same level of what one would do in Prisma, but also supports an "Select" syntax where TS commands more closely resemble SQL queries for cases where performance tuning or other consideration might be helpful.

On a side note, I appreciate the cheekiness of their site. For instance, their pricing page. 😁