How to Setup Auth with Fresh
Cookie-based authentication can be added to a Fresh app with server-side route handlers and std/http cookie helpers, without any client-side JavaScript. A plain HTML form POSTs to a /api/login handler that checks credentials, sets an auth cookie (SameSite=Lax, Secure, 2-minute maxAge) and returns a 303 redirect. A /logout route deletes the cookie, and protected pages either redirect or render conditionally based on the cookie. The example hardcodes credentials and a static cookie value; production use needs unique per-session values and a persistent store such as Redis or MongoDB.
Related posts
- Authenticating users in Astro using Neon Postgres and Lucia Auth
Neon mediumAdept
Lucia Auth and a Neon serverless Postgres database provide cookie-based username/password authentication in an Astro app, with Vercel as the server-side rendering target. The walkthrough provisions a pooled Neon connection, creates auth_user and user_session tables via a tsx script, and configures Lucia's NeonHTTPAdapter with secure session cookies and typed user attributes. Helper functions read and validate the auth_session cookie and check credential formats. These feed sign-in, sign-up and sign-out API routes and a protected page that blocks unauthenticated visitors.
- Fresh 1.0
Deno mediumAdeptFresh is a full stack web framework for Deno that renders pages just-in-time on the server and ships zero JavaScript to the client by default, using the islands architecture so only explicitly opted-in components are hydrated in the browser. It uses Preact and JSX/TSX on both server and client, has file-system routing with handlers for custom responses and async data loading, and has no build step: TypeScript and JSX are transpiled on demand, so deployments are near-instant. Version 1.0 is declared production-ready and is well suited to edge runtimes such as Deno Deploy, Netlify Edge Functions and Supabase Edge Functions.
- Solving the MCP Authentication Headache with Vercel & Better Auth
Neon mediumAdept
Remote MCP servers can authenticate users with OAuth instead of plaintext bearer tokens or UUIDs stored in a client's mcp.json, using Better Auth's MCP plugin together with Vercel's @vercel/mcp-adapter in a Next.js app. Setup touches three files: add the mcp plugin with a login page to the Better Auth config, expose the .well-known/oauth-authorization-server discovery route, and wrap the MCP handler so it resolves the user's session via getMCPSession and returns 401 when none exists. The session's user ID can then scope tool access to that user's own data. Clients such as Cursor, connecting through mcp-remote, open a login popup on first use.
- Supabase is now compatible with Next.js 14
Supabase mediumAdeptSupabase works across every Next.js 14 rendering context, including App Router Client and Server Components, Route Handlers, Server Actions and Middleware, plus the Pages Router data-fetching functions. Now that Server Actions are stable, auth and mutations can run entirely server-side next to the Server Components that fetch data. supabase-js stores sessions in localStorage by default, which doesn't exist on the server, so it has to be configured with cookie-based storage on both server and browser. The new @supabase/ssr package and a create-next-app starter template (`-e with-supabase`) wrap that boilerplate.
- Fresh 1.1 - automatic JSX, plugins, DevTools, and more
Deno mediumAdeptFresh 1.1, Deno's zero-client-JS, no-build-step web framework, switches new projects to automatic JSX via the deno.json jsxImportSource setting. It also adds a first plugin system for injecting styles and scripts, with an official Twind plugin that drops the tw wrapper, plus Preact Signals and Preact DevTools support. Route handlers can call ctx.renderNotFound(), and middleware files can export an array of stacked handlers. Experimental Deno.serve support is opt-in via experimentalDenoServe. An update script with codemods migrates existing projects.