Skip to content

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

Open
@divinepaul

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions