Skip to content

Conversation

diogoparente
Copy link

🚀 Migrate to TanStack Start Beta with Vite + Nitro

Overview

This pull request implements the complete migration from TanStack Start Alpha to the new Beta structure as outlined in the official TanStack Start Beta tracking discussion. This migration modernizes the project architecture by adopting Vite as the primary build tool and restructuring the codebase to be more "Vite-native."

🎯 Motivation

The migration addresses several key improvements introduced in TanStack Start Beta:

  • Vite + Nitro Integration: TanStack Start is now a Vite plugin, providing better performance, faster build times, and improved developer experience
  • Improved API Routes: Migration from API Routes to the enhanced "Server Routes" system with better functionality and developer ergonomics
  • Directory Structure Modernization: Moving from ./app to ./src aligns with Vite ecosystem conventions and provides a better "new user experience"
  • Package Updates: Adoption of the new @tanstack/react-start package (renamed from @tanstack/start)

📋 Changes Implemented

1. Core Infrastructure Updates (8f3d4a9, af120cb)

  • ✅ Migrated from app.config.ts to vite.config.ts with TanStack Start plugin
  • ✅ Updated package.json scripts to use Vite commands (vite dev, vite build)
  • ✅ Updated to latest TanStack dependencies including @tanstack/react-start

2. Directory Structure Migration (9db90f3, d746bb6, dd1534e, 6ba8922, c794897)

  • ✅ Moved entire codebase from ./app/ to ./src/ directory
  • ✅ Updated TypeScript path aliases from app/* to src/*
  • ✅ Migrated all components, hooks, utilities, and route files
  • ✅ Updated all import statements to use @/ alias pointing to ./src/
  • ✅ Cleaned up old directory structure

3. Router Configuration (d2de5ee)

  • ✅ Added required src/router.tsx with createRouter function export
  • ✅ Configured router with scroll restoration and proper TypeScript module declaration

4. API Routes → Server Routes Migration (affbbc9)

  • BREAKING: Migrated from createAPIFileRoute to createServerFileRoute
  • BREAKING: Updated exports from APIRoute to ServerRoute
  • ✅ Enhanced auth API route with new Server Routes capabilities

5. Configuration Updates (4151ec5)

  • ✅ Updated drizzle.config.ts to point to src/database/schema.ts
  • ✅ Updated components.json with new path aliases
  • ✅ Updated .gitignore for new TanStack Start structure

🔄 Breaking Changes

As per the official migration guide:

  1. API Routes Format:

    - export const APIRoute = createAPIFileRoute('/api/auth/$')({
    + export const ServerRoute = createServerFileRoute('/api/auth/$').methods({
  2. Directory Structure: All application code moved from app/ to src/

  3. Configuration: Build system now uses Vite instead of custom TanStack Start configuration

🎉 Benefits

  • Performance: Vite's fast HMR and optimized build process
  • Developer Experience: Better debugging, faster builds, and improved tooling
  • Future-Proof: Aligned with TanStack Start's roadmap and Vite ecosystem
  • Enhanced API Capabilities: Server Routes provide more functionality than the previous API Routes

🔗 References

✅ Testing

  • Development server starts correctly with pnpm dev
  • Build process completes without errors with pnpm build
  • Basic authentication flow works with new Server Routes
  • All components render correctly with new import paths

Note: This migration follows the official TanStack Start Beta guidelines and positions the project for continued compatibility with future TanStack updates.

- Update scripts to use Vite dev/build commands
- Update TanStack dependencies to latest versions
- Add @tanstack/react-start-client dependency

BREAKING CHANGE: Migration from TanStack Start app.config.ts to Vite-based setup
- Add new Vite configuration with TanStack Start plugin
- Configure tsconfigPaths and Tailwind CSS plugins
- Set up path alias for @/* to ./src/*
- Remove old app.config.ts

BREAKING CHANGE: Configuration moved from TanStack Start app.config.ts to Vite configuration
- Update path alias from app/* to src/*
- Maintain @/* alias pointing to ./src/*
- Keep strict TypeScript configuration
- Add createRouter function exported from src/router.tsx
- Include routeTree.gen.ts for route tree generation
- Configure router with scrollRestoration and proper typing

This is required for the new TanStack Start structure
- Move auth-schema.ts from root to src/
- Move database/ directory (schema.ts, db.ts) to src/database/
- Move lib/ directory (auth.ts, auth-client.ts, utils.ts) to src/lib/
- Update imports to use @/ alias for src/ directory

Part of migration from app/ to src/ directory structure
- Move components/ directory to src/components/
  - UI components (button.tsx, dropdown-menu.tsx, sonner.tsx)
  - App components (header.tsx, mode-toggle.tsx)
- Move hooks/ directory to src/hooks/
  - Auth hooks (auth-hooks.ts)
- Update all imports to use @/ path alias

Part of migration from app/ to src/ directory structure
- Migrate API routes to new Server Routes format using createServerFileRoute
- Update auth API route to use ServerRoute export instead of APIRoute
- Move all route files from app/routes/ to src/routes/
- Update imports to use @/ path alias

BREAKING CHANGE: API routes now use ServerRoute export with createServerFileRoute
- Move providers.tsx to src/
- Move logo.svg to src/
- Move types/ directory to src/types/
- Move styles/ directory to src/styles/
- Update all imports to use @/ path alias

Completes migration from app/ to src/ directory structure
- Remove all files from app/ directory (routes, api.ts, client.tsx, ssr.tsx, etc.)
- Remove old component, database, hooks, lib, and styles directories from root
- Remove auth-schema.ts from root
- Clean up old TanStack Start structure

BREAKING CHANGE: All application code moved from app/ to src/ directory
- Update drizzle.config.ts to point to src/database/schema.ts
- Update components.json to use src path aliases
- Update .gitignore for new TanStack Start structure

Completes TanStack Start migration to Vite-based setup
Copy link

vercel bot commented Jun 26, 2025

@diogoparente is attempting to deploy a commit to the Better Auth Team on Vercel.

A member of the Team first needs to authorize it.

- Add .output to .gitignore to exclude generated files from version control
- Add aria-label to GitHub link for screen readers
- Add sr-only span text to GitHub button
- Ensures all interactive elements have discernible names

Fixes accessibility violations where buttons and links lacked accessible names
- Add descriptive meta description tag to document head
- Improves SEO and search engine visibility
- Uses consistent description with project manifest

Fixes missing meta description issue
@diogoparente diogoparente marked this pull request as ready for review June 27, 2025 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant