Meta tags:
Headings (most frequently used words):
sign, session, create, auth, instance, client, side, in, out, get, introduction, better, update, the, route, handler, management, protecting, resources, database, models, wrapping, up, server, comparison, customization, about, js, download, acknowledgements,
Text of the page (most frequently used words):
auth (133), better (62), the (36), from (29), import (26), and (25), #session (20), client (18), const (17), for (16), github (15), database (14), you (13), next (13), lib (13), headers (12), await (12), includes (10), uses (10), sign (10), here (10), authclient (9), with (8), out (8), are (8), between (8), differences (8), data (8), use (8), get (8), signout (8), using (7), instead (7), this (7), export (7), api (7), signin (7), migrate (6), management (6), provider (6), div (6), side (6), instance (6), introduction (5), more (5), app (5), models (5), can (5), not (5), table (5), redirect (5), page (5), error (5), getting (5), schema (4), also (4), fields (4), timestamps (4), updatedat (4), createdat (4), your (4), dashboardpage (4), usesession (4), server (4), proxy (4), route (4), example (4), protecting (4), resources (4), current (4), signing (4), users (4), oauth (4), update (4), react (4), create (4), project (4), started (4), azure (4), security (3), installation (3), need (3), migration (3), now (3), authentication (3), have (3), core (3), see (3), were (3), like (3), verification (3), token (3), while (3), name (3), user (3), comparison (3), return (3), ispending (3), handlers (3), nextauth (3), process (3), providers (3), discord (2), community (2), our (2), check (2), offers (2), features (2), explore (2), full (2), wrapping (2), logic (2), type (2), custom (2), concepts (2), customization (2), does (2), any (2), optional (2), removed (2), them (2), used (2), expires (2), expiresat (2), support (2), primary (2), key (2), verificationtoken (2), field (2), providerid (2), account (2), emailverified (2), has (2), section (2), stateless (2), will (2), default (2), welcome (2), getsession (2), navigation (2), dashboard (2), tsx (2), middleware (2), recommend (2), checks (2), active (2), when (2), information (2), tonextjshandler (2), post (2), file (2), handler (2), createauthclient (2), set (2), without (2), env (2), betterauth (2), starting (2), guide (2), setup (2), strongly (2), migrating (2), identity (2), credentials (2), inc, 2026, contributors, acknowledgements, npm, download, about, help, join, reach, contact, com, ready, complete, implementation, multiple, methods, greater, flexibility, sure, unlock, its, potential, documentation, demo, may, extended, implemented, additional, allows, customize, safe, way, define, during, lifecycle, operations, details, note, that, introduce, breaking, changes, rarely, refresh_token_expires_in, oauth_token, oauth_token_secret, various, types, value, single, composite, removes, session_state, token_type, determined, built, credential, password, refreshtokenexpiresat, accesstokenexpiresat, distinguish, internal, accountid, camelcase, naming, refresh_token, refreshtoken, useragent, ipaddress, sessiontoken, boolean, timestamp, required, email, just, compare, two, both, provide, jwt, strategies, strategy, plan, continue, async, pending, approaches, but, handling, each, rather, than, layout, basic, intended, slow, fetching, helpful, optimistic, such, permission, based, redirects, should, authorization, solution, docs, success, body, signinsocial, url, isrefetching, refetch, status, social, look, how, manage, sessions, compared, rename, folder, avoid, confusion, then, follows, all, functions, interacting, supports, adapter, refer, below, github_client_secret, clientsecret, github_client_id, clientid, socialproviders, before, follow, however, new, facing, challenges, roadmap, previously, exclusive, hope, unite, ecosystem, causing, fragmentation, walk, through, steps, since, these, projects, different, design, philosophies, requires, careful, planning, work, working, well, there, urgent, team, continues, handle, patches, critical, issues, edit, question, give, feedback, integrations, xata, upstash, redis, unstorage, typeorm, surrealdb, supabase, sequelize, prisma, pouchdb, postgresql, neon, neo4j, mongodb, mikroorm, kysely, hasura, firebase, firestore, faunadb, edgedb, dynamodb, drizzle, dgraph, cloudflare, tables, adapters, zoom, zoho, zitadel, yandex, workos, wordpress, wikimedia, webex, vipps, mobilepay, united, effects, twitter, twitch, trakt, todoist, tiktok, threads, strava, spotify, slack, simplelogin, sendgrid, salesforce, sailpoint, resend, reddit, postmark, pipedrive, pinterest, patreon, passkey, passage, osu, osso, onelogin, okta, notion, nodemailer, nextcloud, netsuite, netlify, naver, microsoft, entra, medium, mattermost, mastodon, mailru, mailgun, mailchimp, loops, logto, linkedin, line, keycloak, kakao, instagram, server4, hubspot, google, gitlab, fusionauth, frontegg, freshbooks, foursquare, forwardemail, figma, faceit, facebook, eveonline, duende, server6, dropbox, dribbble, descope, coinbase, cognito, click, bungie, boxyhq, saml, box, bitbucket, beyondidentity, battlenet, bankid, norge, devops, b2c, authentik, auth0, asgardeo, apple, school, connections, typescript, deployment, pages, webauthn, magic, links, light, ask, reference, guides, part, skip, content,
Text of the page (random words):
migrating from auth js to better auth skip to content the auth js project is now part of better auth auth js getting started guides api reference concepts security ai ask ai github 22 2k light introduction migrate to better auth getting started installation authentication oauth magic links credentials webauthn database session management signin and signout get session protecting resources custom pages deployment typescript connections providers 42 school apple asgardeo auth0 authentik azure ad azure ad b2c azure devops bankid norge battlenet beyondidentity bitbucket box boxyhq saml bungie click up cognito coinbase credentials descope discord dribbble dropbox duende identity server6 eveonline facebook faceit figma forwardemail foursquare freshbooks frontegg fusionauth github gitlab google hubspot identity server4 instagram kakao keycloak line linkedin logto loops mailchimp mailgun mailru mastodon mattermost medium microsoft entra id naver netlify netsuite nextcloud nodemailer notion okta onelogin osso osu passage passkey patreon pinterest pipedrive postmark reddit resend sailpoint salesforce sendgrid simplelogin slack spotify strava threads tiktok todoist trakt twitch twitter united effects vipps mobilepay vk webex wikimedia wordpress workos yandex zitadel zoho zoom adapters azure tables cloudflare d1 dgraph drizzle dynamodb edgedb faunadb firebase firestore hasura kysely mikroorm mongodb neo4j neon postgresql pouchdb prisma sequelize supabase surrealdb typeorm unstorage upstash redis xata integrations migrating to v5 on this page introduction 1 create better auth instance 2 create client instance 3 update the route handler 4 session management client side sign in sign out get session server side sign in sign out get session 5 protecting resources 6 database models comparison customization wrapping up question give us feedback edit this page on github getting started migrate to better auth introduction in this guide we ll walk through the steps to migrate a project from auth js to better auth since these projects have different design philosophies the migration requires careful planning and work if your current setup is working well there s no urgent need to migrate better auth team continues to handle security patches and critical issues for auth js however if you re starting a new project or facing challenges with your current setup we strongly recommend using better auth our roadmap includes features previously exclusive to auth js and we hope this will unite the ecosystem more strongly without causing fragmentation 1 create better auth instance before starting the migration process set up better auth in your project follow the installation guide to get started for example if you use the github oauth provider here is a comparison of the auth ts file auth js better auth import nextauth from next auth import github from next auth providers github export const handlers signin signout auth nextauth providers github import betterauth from better auth export const auth betterauth socialproviders github clientid process env github_client_id clientsecret process env github_client_secret now better auth supports stateless session management without any database if you were using a database adapter in auth js you can refer to the database models below to check the differences with better auth s core schema 2 create client instance this client instance includes a set of functions for interacting with the better auth server instance for more information see here auth client ts import createauthclient from better auth react export const authclient createauthclient 3 update the route handler rename the app api auth nextauth folder to app api auth all to avoid confusion then update the route ts file as follows auth js better auth import handlers from lib auth export const get post handlers import auth from lib auth import tonextjshandler from better auth next js export const post get tonextjshandler auth 4 session management in this section we ll look at how to manage sessions in better auth compared to auth js for more information see here client side sign in here are the differences between auth js and better auth for signing in users for example with the github oauth provider auth js better auth use client import signin from next auth react signin github use client import authclient from lib auth client const data error await authclient signin social provider github sign out here are the differences between auth js and better auth when signing out users auth js better auth use client import signout from next auth react signout use client import authclient from lib auth client const data error await authclient signout get session here are the differences between auth js and better auth for getting the current active session auth js better auth use client import usesession from next auth react const data status update usesession use client import authclient from lib auth client const data error refetch ispending isrefetching authclient usesession server side sign in here are the differences between auth js and better auth for signing in users for example with the github oauth provider auth js better auth import signin from lib auth await signin github import auth from lib auth const redirect url await auth api signinsocial body provider github sign out here are the differences between auth js and better auth when signing out users auth js better auth import signout from lib auth await signout import auth from lib auth import headers from next headers const success await auth api signout headers await headers get session here are the differences between auth js and better auth for getting the current active session auth js better auth import auth from lib auth const session await auth import auth from lib auth import headers from next headers const session await auth api getsession headers await headers 5 protecting resources proxy middleware is not intended for slow data fetching while proxy can be helpful for optimistic checks such as permission based redirects it should not be used as a full session management or authorization solution next js docs auth js offers approaches using proxy middleware but better auth recommend handling auth checks on each page or route rather than in a proxy or layout here is a basic example of protecting resources with better auth client side server side app dashboard page tsx use client import authclient from lib auth client import redirect from next navigation const dashboardpage const data error ispending authclient usesession if ispending return div pending div if data error redirect sign in return div h1 welcome data user name h1 div export default dashboardpage app dashboard page tsx import auth from lib auth import headers from next headers import redirect from next navigation const dashboardpage async const session await auth api getsession headers await headers if session redirect sign in return div h1 welcome session user name h1 div export default dashboardpage 6 database models both auth js and better auth provide stateless jwt and database session strategies if you were using the database session strategy in auth js and plan to continue using it in better auth you will also need to migrate your database just like auth js has database models better auth also has a core schema in this section we ll compare the two and explore the differences between them auth js better auth comparison table user name email and emailverified are required in better auth while optional in auth js emailverified uses a boolean in better auth while auth js uses a timestamp better auth includes createdat and updatedat timestamps table session better auth uses token instead of sessiontoken better auth uses expiresat instead of expires better auth includes ipaddress and useragent fields better auth includes createdat and updatedat timestamps table account better auth uses camelcase naming e g refreshtoken vs refresh_token better auth includes accountid to distinguish between the account id and internal id better auth uses providerid instead of provider better auth includes accesstokenexpiresat and refreshtokenexpiresat for token management better auth includes password field to support built in credential authentication better auth does not have a type field as it s determined by the providerid better auth removes token_type and session_state fields better auth includes createdat and updatedat timestamps table verificationtoken verification better auth uses verification table instead of verificationtoken better auth uses a single id primary key instead of composite primary key better auth uses value instead of token to support various verification types better auth uses expiresat instead of expires better auth includes createdat and updatedat timestamps if you were using auth js v4 note that v5 does not introduce any breaking changes to the database schema optional fields like oauth_token_secret and oauth_token can be removed if you are not using them rarely used fields like refresh_token_expires_in can also be removed customization you may have extended the database models or implemented additional logic in auth js better auth allows you to customize the core schema in a type safe way you can also define custom logic during the lifecycle of database operations for more details see concepts database wrapping up now you re ready to migrate from auth js to better auth for a complete implementation with multiple authentication methods check out the next js demo app better auth offers greater flexibility and more features so be sure to explore the documentation to unlock its full potential if you need help with migration join our community or reach out to contact better auth com introduction installation about auth js introduction security discord community download github npm acknowledgements contributors auth js better auth inc 2026
|