News for hackers. Stuff that matters.
Re:Ask HN: What's your go-to tech stack (or services/product... by reducesuffering on Thursday May 30, 2024 @01:45PM (#40526540)
Next.js on Vercel

A complete frontend+backend page at /my_path with a file at /my_path/page.tsx with ~20 lines in a single file that handles backend request, DB query, backend response, frontend html templating and client-side JS interactivity.

Re:Ask HN: What's your go-to tech stack (or services/product... by runjake on Thursday May 30, 2024 @05:50PM (#40529103)
Would you happen to have a code example, or something close to it, posted somewhere?
Re:Ask HN: What's your go-to tech stack (or services/product... by reducesuffering on Friday May 31, 2024 @02:42AM (#40532120)
I included dynamic path/routes as a bonus.

  Internal path is app/[stateName]/page.tsx
  Public route is domainName.com/(any state name)
// Prisma is ORM that handles DB req/res

  async function getStateInfo(stateName: string) {
  const state: State | null = await prisma.state.findUnique({
    where: { name: stateName },
  });
  return state;
}

type StatePageParams = { params: { stateName: string }};

export default async function StatePage({ params }: StatePageParams) {

  const stateInfo = await getStateInfo(params.stateName);

  return (
      <main className="container flex flex-col items-center justify-center p-2">
        {stateInfo ? (
          <div>
              <h1 className="text-lg"> {stateInfo.name} </h1>
          </div>
          <InteractiveClientCard />
        ) : null}
      </main>
  );
}