SShortSingh.
Back to feed

NextAuth v5 silently switches session storage based on adapter configuration

0
·1 views

NextAuth (Auth.js) v5 determines session strategy implicitly: without an adapter it defaults to JWT, but adding an adapter like DrizzleAdapter silently shifts session storage to the database. A key complication arises with the Credentials provider, which cannot create database sessions, causing a silent authentication failure when an adapter is present without an explicit JWT override. Developers must set session: { strategy: 'jwt' } globally when using Credentials, since NextAuth does not support mixing strategies per provider. One practical workaround is to enable the Credentials provider only in non-production environments, switching to JWT strategy exclusively for testing while keeping OAuth on database sessions in production. Understanding these two implicit rules resolves common NextAuth puzzles such as undefined token values in callbacks and logins that appear to succeed but produce no active session.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How a Prefix Sum and Hashmap Cut a Coding Problem from O(n²) to O(n)

A developer tackled the classic 'longest subarray with sum equal to k' problem, initially using a brute-force approach with two nested loops that timed out on large inputs of 100,000 elements. The breakthrough came by shifting focus to prefix sums, where the sum of any subarray can be derived from the difference of two cumulative totals. A hashmap is used to store the earliest index at which each prefix sum was seen, allowing the algorithm to find valid subarrays in a single linear pass. Each step requires only a constant-time hashmap lookup, bringing overall time complexity down from O(n²) to O(n). The approach illustrates a broader problem-solving principle: reusing previously computed work rather than recalculating it from scratch.

0
ProgrammingDEV Community ·

Why LLM Statelessness Makes the Memory Harness the True Brain of AI Agents

Large language models are stateless by design, meaning they retain no information between API calls — every memory feature in tools like ChatGPT or Claude is managed externally, not inside the model itself. Researchers have increasingly formalized this principle, with frameworks like MemGPT (2023), StateFlow (2024), and ClawVM (2026) treating the LLM as a pure processing unit and the surrounding system as the intelligent layer. This shifts the burden of agent intelligence entirely onto the memory harness — the component that decides what context to retrieve and inject into each prompt. One approach gaining attention uses temporal assertions, which are structured facts tagged with validity periods, so outdated information is automatically excluded from the model's context. An open-source project called Smriti implements this model using a PostgreSQL backend under the MIT license, positioning the harness — not the LLM — as the true agent.

0
ProgrammingHacker News ·

RFC 8890 Argues Internet Standards Must Prioritize End Users Above All

RFC 8890, published in 2020 by the Internet Architecture Board, establishes that the Internet is fundamentally for end users. The document argues that when conflicts arise between the interests of users, operators, and other stakeholders, the IETF should prioritize end users. It provides guidance for protocol designers to consider user welfare as a core principle when developing Internet standards. The RFC gained renewed attention on Hacker News, sparking discussion about how well the principle has been upheld in practice.

0
ProgrammingDEV Community ·

Wise's Bank Charter Rejection Offers Key Lessons in Resilient Payment Architecture

Wise's stock fell roughly 10% after US regulators denied the fintech firm's application for a national trust bank charter, which it had sought to gain direct access to Federal Reserve payment rails and cut costs. In response, Wise pivoted its backend strategy toward digital asset frameworks, including stablecoin rails being shaped by the GENIUS Act. A systems engineering analysis of the episode highlights the risks of tightly coupling payment applications to a single banking rail or API, which can cause total failure if that rail is disrupted or blocked. Experts recommend using an abstract provider pattern so that fiat and digital settlement rails are interchangeable without rewriting core application logic. An event-driven ledger architecture — where funds are reserved locally before asynchronous dispatch and reconciled only upon confirmed settlement — is also advised to prevent indeterminate system states during outages.