Skip to content

server routes with a .ts extension gets the wrong boilerplate while creating the file. #4462

Description

@divinepaul

Which project does this relate to?

Router

Describe the bug

Using the start-basic example, I tried to create a new .ts file under /routes/api. howerver, i get the wrong boilerplate filled in.

import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/api/users')({
  component: RouteComponent,
})

function RouteComponent() {
  return <div>Hello "/api/users"!</div>
}

instead of something like this.

export const ServerRoute = createServerFileRoute().methods({
  GET: async ({ request }) => {
    return new Response('Hello, World!')
  },
})

Your Example Website or App

https://stackblitz.com/edit/github-orkptmtq?file=src%2Froutes%2Fapi%2Fuser.ts

Steps to Reproduce the Bug or Issue

Try to create any server routes in the stackblitz example ( assuming they are created with a .ts extention )

Expected behavior

I wanted the right boilerplate to be filled in.

Screenshots or Videos

No response

Platform

  • OS: Fedora 42
  • Version:
"@tanstack/react-router": "^1.121.24",
"@tanstack/react-router-devtools": "^1.121.24",
"@tanstack/router-plugin": "^1.121.25",

Additional context

No response

Activity

  1. schiller-manuel commented on Jun 18, 2025

    @schiller-manuel
    Collaborator

    that's not a bug really, rather a feature request.
    I get it though and we should make the scaffolding logic customizable so you can implement this yourself.

  2. added
    enhancement
    on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions