With Next, you have a few different options when it comes to page rendering: you can choose to do it “on-demand” (server-side rendering) or ahead of time (static site generation). I've opted to build all the blog posts ahead of time, when the site is generated.
I also use Next's API Route for things that require persistence in the backend. I use MongoDB as my database, to store stuff like the # of likes each post has.
I deploy this blog on Vercel. I initially chose them because they're the company behind Next.js, and I figured it would be well-optimized. Honestly, their platform is awesome. I wound up moving some of my non-Next projects there as well.
export const incrementVote = async (tilId: string) => {
const userId = await checkAuth();
await db.transaction(async (tx) => {
await tx
.update(tils)
.set({ upvotes: sql`${tils.upvotes}+1` })
.where(eq(tils.id, tilId));
await tx.insert(upvotes).values({ userId, tilId });
});
};