Skip to content

Conversation

@andremonteiro95
Copy link
Contributor

This PR adds support for specifying a base path for TanStack Start apps, enabling deployment to specific paths.

@vimtor vimtor self-assigned this Dec 13, 2025
@vimtor
Copy link
Collaborator

vimtor commented Dec 18, 2025

thanks for the contribution @andremonteiro95

how did you configure the vite.config.ts?

i'm getting this error when trying your code:

CleanShot 2025-12-18 at 16 39 14@2x

@andremonteiro95
Copy link
Contributor Author

My vite.config.ts looks like the snippet below.

const config = defineConfig(() => {
  const base = process.env.BASE_PATH || undefined

  return {
    base,
    plugins: [
      devtools(),
      nitro({
        baseURL: base,
        preset: 'aws-lambda'
      }),
      // this is the plugin that enables path aliases
      viteTsConfigPaths({
        projects: ['./tsconfig.json']
      }),
      tanstackStart({
        spa: {
          enabled: true
        }
      }),
      viteReact({
        babel: {
          plugins: ['babel-plugin-react-compiler']
        }
      })
    ]
  }
})

export default config

I generate the BASE_PATH in my SST file just like:

const BASE_PATH = isPermanentStage ? undefined : `/${$app.stage}`

export const web = new sst.aws.TanStackStart('Web', {
  environment: {
    ...(BASE_PATH ? { BASE_PATH } : {})
  },

  // ...
})

@vimtor
Copy link
Collaborator

vimtor commented Jan 13, 2026

thanks for sharing @andremonteiro95

the pr should be working but the router path doesn't seem to be equal to the baseURL

CleanShot 2026-01-13 at 17 39 19@2x

could you share a screenshot of your pr code working? any ideas why it doesn't work given the screenshot i attached

@andremonteiro95
Copy link
Contributor Author

From the screenshot alone, I'd guess you're missing the base property of Vite's config - that seems to be the only thing that differs from my config.

@vimtor
Copy link
Collaborator

vimtor commented Jan 13, 2026

nice catch @andremonteiro95

now the only issue is that JS files are being requested from the base path but instead of the root

CleanShot 2026-01-13 at 19 06 25@2x

@andremonteiro95
Copy link
Contributor Author

Can you send a reproducible example?

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.

2 participants