-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Describe the bug
All my pages are statically generated. I only run queries at build time. If I create my client with createClient from next-sanity there is a significant bundle increase in each of my pages where I'm using the client. On the other hand if I import it straight from the @sanity/client package the sanity client don't end up in my client bundle.
I also embed sanity studio in my NextJS application. If I remove it @sanity/next-loadergets into my bundle. (see screenshots)
To Reproduce
Steps to reproduce the behavior:
- Create sanity client with createClient from
- Fetch Sanity in NextJS App Router.
- Run build with
@next/bundle-analyzer.
Expected behavior
To not increase my client-side bundle with unnecessary code.
Screenshots
I run next build with @next/bundle-analyzer.
With Sanity Studio:
Without Sanity Studio:
Which versions of Sanity are you using?
@sanity/cli (global) 4.6.1 (up to date)
@sanity/image-url 1.2.0 (up to date)
@sanity/locale-hu-hu 1.1.26 (up to date)
@sanity/vision 4.6.1 (up to date)
sanity 4.6.1 (up to date)
What operating system are you using?
macOs 15.6.1 (24G90)
Which versions of Node.js / npm are you running?
node: v22.17.0
pnpm: 10.15.1
Additional context
Sanity env (projectId, dataset....) is being shared between the studio and the client.