Skip to content

Frontend for a complete session-based user authentication, with styled forms. Vite, React, TypeScript.

License

Notifications You must be signed in to change notification settings

aabbtree77/auth-starter-frontend

Repository files navigation

"The narrowest path is always the holiest." - Depeche Mode, 1993

Introduction

This is the second iteration of my quest for the holy grail, i.e. the best way to build CRUD web apps.

Previously, I have considered metaframeworks: Next.js, SvelteKit, and Astro. However, they are not reliable, they only allow you to move faster initially for certain types of VC-funded business settings.

Therefore, I have removed Astro by splitting everything into frontend (Vite + React) and backend (Hono + Drizzle + bun:sqlite). I have removed Lucia and rewrote authentication from scratch too. DB is now an explicitly controlled system, not a connector/adapter thing.

This code is the frontend part. See the accompanied backend.

bun install
bun run dev

If this breaks, start with bun create hono my-app and recreate the structure.

Notice that I did not place .env inside .gitignore.

Decisions Made

  1. No emails and complex workflows, hence no password resets, might add a social login as an escape hatch some day.

  2. Only a single active user session is allowed. Managing multiple sessions with multiple cookies with all the permutations and expiry times, do you really want to go there?

  3. Only the bun run dev mode.

  4. Almost no middleware.

Some Thoughts About (BE + FE) vs Metaframeworks

Pros of (BE + FE):

  • No need to dwell on what a server-side React is, could be, will be.

  • Feels like learning what the web is, as opposed to, say, Next.js.

These advantages are huge, esp. when considering how broken everything is.

Cons of (BE + FE):

  • Two projects instead of one. Separate github repos, build systems, .env shenanigans, BE vs FE routing, docs, hosting... With dev and prod branches this becomes four.

  • Some choice paralysis, but this holds mostly for the backend, and it is not very severe. Express vs say Hono, SQLite vs PostgreSQL, Drizzle with the SQL strings (select) vs Drizzle all the way (query), Bun vs Node.

  • A lot of people are now pushing metaframeworks. Next.js is no Unity/Unreal, but still something to watch for.

Releases

No releases published

Packages

No packages published