Skip to content

TanStack Start: Build fails on useServerFn hook when RSCs are used in the app #7276

Description

@iurii-kyrylenko

Which project does this relate to?

Start

Describe the bug

There is a build error when an RSC in one route is used along with the useServerFn hook in another route.

Your Example Website or App

https://github.com/iurii-kyrylenko/rsc-sf

Steps to Reproduce the Bug or Issue

  1. Clone repo from

https://github.com/iurii-kyrylenko/rsc-sf

  1. Install

npm install

  1. Run in dev mode

npm run dev

  1. Build for prod

npm run build

  1. The routes

  • /with-rsc : Renders a server component
  • /with-sf : With the useServerFn hook
  1. The issue

When running in dev mode the app works as expected without errors.

Build for production fails with error:

[MISSING_EXPORT] Error: "useServerFn" is not exported by "node_modules/@tanstack/react-start/dist/esm/index.rsc.js".
   ╭─[ src/routes/with-sf.tsx:2:10 ]
   │
 2 │ import { useServerFn } from "@tanstack/react-start";
   │          ─────┬─────  
   │               ╰─────── Missing export
───╯

Expected behavior

There is no error when building the app for production.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.168.22 / 1.167.49
  • OS: macOS
  • Browser: any
  • Browser Version:
  • Bundler: vite
  • Bundler Version: 8.0.10

Additional context

No response

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions