Skip to content

npm create @tanstack/start@latest, when set up with Query also includes Provider, but it is not used. #272

@Ashvith10

Description

@Ashvith10

Which project does this relate to?

Create Tanstack App

Describe the bug

When setting up npm create @tanstack/start@latest, it also creates the folder src/integrations/tanstack-query with two files inside:

  • root-provider.tsx
  • devtools.tsx

Inside root-provider.tsx, there is a Provider function (see both tRPC and non-tRPC snippet below)

export function Provider({
children,
queryClient,
}: {
children: React.ReactNode;
queryClient: QueryClient;
}) {
return (
<TRPCProvider trpcClient={trpcClient} queryClient={queryClient}>
{children}
</TRPCProvider>
);
}

export function Provider({
children,
queryClient,
}: {
children: React.ReactNode;
queryClient: QueryClient;
}) {
return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
}

They are not used anywhere in the template, and from the page TanStack Query Integration:

By default, the integration wraps your router with a QueryClientProvider. If you already provide your own provider, pass wrapQueryClient: false and keep your custom wrapper.

The code in the template is unused, so it may be removed.

Your Example Website or App

https://tanstack.com/start/v0/docs/framework/react/quick-start

Steps to Reproduce the Bug or Issue

  1. Create a basic app with npm create @tanstack/start@latest my-app -- --add-ons tanstack-query
  2. View the contents of src/integrations/tanstack-query/root-provider.tsx with cat:
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

export function getContext() {
  const queryClient = new QueryClient()
  return {
    queryClient,
  }
}

export function Provider({
  children,
  queryClient,
}: {
  children: React.ReactNode
  queryClient: QueryClient
}) {
  return (
    <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
  )
}
  1. Look for files where Provider is mentioned with grep:
$ grep -nr "\bProvider" --exclude-dir=node_modules
src/integrations/tanstack-query/root-provider.tsx:10:export function Provider({

As we can see, excluding the file where it was defined, it is not used anywhere else.

Expected behavior

As a user, I expect unused code snippets to not be part of our template. However, in our case, there is a unused code that returns a QueryClientProvider, which is not used anywhere, and which won't be needed, since Router also has Query integration.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Browser: Firefox
  • Version: 146.0-2

Additional context

No response

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