Skip to content
Source
Sign inSign up
TanStack/cli

fix(create): generate Better Auth ORM tables and adapters #568

Mergedtannerlinsleymerged 3 commits intomain fromrefs/pull/568/headmerged by tannerlinsley

tannerlinsleycommented

Better Auth currently remains stateless when a generated app selects Drizzle or Prisma, and neither ORM schema contains its auth tables. This configures the selected adapter and includes the user, session, account and verification tables for all three database choices. Standalone Better Auth keeps its existing stateless configuration.

The dependency minimum moves to Better Auth 1.7.18 and matching adapters, excluding the known vulnerable older versions. Setup instructions cover creating the tables and regenerating the Prisma client. MySQL uses text columns for non-indexed auth values so image URLs and tokens are not limited to varchar lengths.

Fixes #443.

Validation:

  • Normal Husky hook passed all ten workspace builds, lint, 569 unit tests and eight blocking browser cases.
  • Generated Drizzle schemas type-check for PostgreSQL, MySQL and SQLite. Prisma validates all three schemas.
  • Fresh Drizzle and Prisma SQLite apps build, type-check and pass signup, persisted session lookup and password sign-in through the generated auth handler.
  • Adding Better Auth to an existing Drizzle SQLite app builds and type-checks. Standalone auth builds without an ORM adapter.
  • Strict npm resolution passed for both ORM combinations. Patched graphs have no Better Auth, high or critical advisories; the Drizzle tool advisories match the ORM-only baseline exactly.
  • All provider traffic remained blocked. PostgreSQL and MySQL validation covers schemas and types, not live database servers.

The first browser attempt failed when npm extraction ran out of disk space. Its logs established ENOSPC; the unchanged suite passed after free space recovered. No checks were weakened.

Artifact check: CLI JavaScript is unchanged. The sum of separately gzipped create-package JavaScript files increases by 5,715 bytes, including generated worker template data. No repository size limit is exceeded.

Summary by CodeRabbit

  • New Features
    • Generated Better Auth setups now include the required authentication tables and configure the matching Drizzle or Prisma adapter when an ORM is selected.
    • Setup instructions now reflect the selected ORM, including database configuration and generation commands where applicable.
    • Better Auth dependencies in generated projects now require version 1.7.18 or newer.
    1. 🦋 Changeset detected

      Latest commit: f90395277de45128c3a4d4ff383e81fe4f2c68cc

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 7 packages
      NameType
      @tanstack/createPatch
      create-start-appPatch
      create-tanstack-appPatch
      create-tanstackPatch
      create-tsrouter-appPatch
      @tanstack/create-startPatch
      @tanstack/cliPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Generated Better Auth projects now include Drizzle or Prisma auth tables when the corresponding ORM is selected. The templates configure the matching adapter and show ORM-specific setup instructions. Tests cover the generated schemas and configuration across PostgreSQL, MySQL, and SQLite.

      Changes: Better Auth ORM setup

      Layer / File(s)Summary
      Generate Better Auth ORM schemas
      packages/create/src/frameworks/react/add-ons/drizzle/assets/src/db/schema.ts.ejs, packages/create/src/frameworks/react/add-ons/drizzle/package.json.ejs, packages/create/src/frameworks/react/add-ons/prisma/assets/prisma/schema.prisma.ejs
      The Drizzle and Prisma templates conditionally add the user, session, account, and verification tables or models. Drizzle uses a different drizzle-orm version when Better Auth is enabled.
      Configure generated Better Auth
      packages/create/src/frameworks/react/add-ons/better-auth/assets/src/lib/auth.ts, packages/create/src/frameworks/react/add-ons/better-auth/assets/src/lib/auth.ts.ejs, packages/create/src/frameworks/react/add-ons/better-auth/package.json, packages/create/src/frameworks/react/add-ons/better-auth/package.json.ejs
      The auth template configures the selected ORM adapter and provider. The package template sets Better Auth to ^1.7.18 and conditionally adds the matching adapter dependency.
      Document and test ORM setup
      packages/create/src/frameworks/react/add-ons/better-auth/README.md.ejs, packages/create/tests/better-auth-orm.test.ts, .changeset/bright-auth-tables.md
      The README template provides ORM-specific setup instructions. Tests cover generated schemas and configuration across the supported database names, including standalone Better Auth. The changeset records the package update.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix

      Suggested reviewers: mrtanoshii

      Merge Risk: Minimal · up to f9039

      Generated Better Auth apps now include the auth tables and the matching ORM adapter configuration. No actionable merge-blocking issue was found. PostgreSQL and MySQL were validated only for schemas and types, not against live servers.

      Pre-merge checks: Passed 5

      Check nameStatusExplanation
      Description CheckPassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title checkPassedThe title clearly summarizes the generation of Better Auth ORM tables and adapter configuration.
      Linked Issues checkPassed[​#443] The Drizzle and Prisma schema templates add the user, session, account, and verification tables for supported databases when Better Auth is enabled. The auth template configures the selected a…
      Out of Scope Changes checkPassed[​#443] Adapter configuration, dependency updates, setup instructions, tests, and the changeset support the generated auth tables. The summary shows no unrelated changes.
      Docstring CoveragePassedNo eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
      Full details: Linked Issues check

      Explanation

      [​#443] The Drizzle and Prisma schema templates add the user, session, account, and verification tables for supported databases when Better Auth is enabled. The auth template configures the selected adapter. Automated template tests cover both ORMs, database choices, and standalone auth.

      Full details: Docstring Coverage

      Explanation

      No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (7 skipped: 7 unsupported.)

      Finishing Touches

      Generate docstrings

      • Commit to this branch
      • Create a new PR
      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Warning

      Some tools did not complete. Review the errors below.

      ESLint

      If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

      packages/create/tests/better-auth-orm.test.ts

      Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser. The file was not found in any of the provided project(s): packages/create/tests/better-auth-orm.test.ts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share

      Recent review info

      Run configuration

      • Source mode: Auto
      • Repository: Unavailable
      • Branch: Unavailable
      • File: No configuration file from this repository applied
      • Commit: Unavailable
      • Layers: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 975b93d0-796c-4972-8fd8-9ae381cb5e54
      Commits

      Reviewing files that changed from the base of the PR and between 15cb17b4382c5f82c0b46bbac524900ee949c4b3 and f90395277de45128c3a4d4ff383e81fe4f2c68cc.

      Files selected for processing: 10

      • .changeset/bright-auth-tables.md
      • packages/create/src/frameworks/react/add-ons/better-auth/README.md.ejs
      • packages/create/src/frameworks/react/add-ons/better-auth/assets/src/lib/auth.ts
      • packages/create/src/frameworks/react/add-ons/better-auth/assets/src/lib/auth.ts.ejs
      • packages/create/src/frameworks/react/add-ons/better-auth/package.json
      • packages/create/src/frameworks/react/add-ons/better-auth/package.json.ejs
      • packages/create/src/frameworks/react/add-ons/drizzle/assets/src/db/schema.ts.ejs
      • packages/create/src/frameworks/react/add-ons/drizzle/package.json.ejs
      • packages/create/src/frameworks/react/add-ons/prisma/assets/prisma/schema.prisma.ejs
      • packages/create/tests/better-auth-orm.test.ts
      Files with no reviewable changes: 2

      • packages/create/src/frameworks/react/add-ons/better-auth/package.json
      • packages/create/src/frameworks/react/add-ons/better-auth/assets/src/lib/auth.ts

      Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

    3. tannerlinsley merged thisb3e1ab0

    4. tannerlinsley closed this

Sign in to join this conversation.