
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis error typically occurs when you're using LiveQueryProvider in a Next.js App Router environment. The "Element type is invalid. Received a promise that resolves to: [object Object]" error is React's way of telling you that a component is being treated as an async function when it shouldn't be.
The issue is likely that LiveQueryProvider is being imported or used in a way that conflicts with Next.js 14's Server Components architecture. In Next.js 14 with the App Router, components are Server Components by default, and client-side providers need to be explicitly marked with 'use client'.
The good news is that LiveQueryProvider is actually part of an older preview approach. The modern, recommended way to handle live content updates in next-sanity is using the Live Content API with defineLive and SanityLive.
Here's how to migrate to the modern approach:
defineLiveCreate a file to configure your live content setup:
// sanity/lib/live.ts
import { createClient } from 'next-sanity'
import { defineLive } from 'next-sanity'
const client = createClient({
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!,
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET!,
apiVersion: '2024-01-01',
useCdn: true,
stega: { studioUrl: '/studio' },
})
export const { sanityFetch, SanityLive } = defineLive({
client,
serverToken: process.env.SANITY_API_READ_TOKEN,
browserToken: process.env.NEXT_PUBLIC_SANITY_API_READ_TOKEN,
})SanityLive to your layoutThe SanityLive component handles live updates and must be added to your root layout:
// app/layout.tsx
import { SanityLive } from '@/sanity/lib/live'
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<SanityLive />
</body>
</html>
)
}sanityFetch in your componentsReplace your existing data fetching with sanityFetch:
// app/page.tsx
import { sanityFetch } from '@/sanity/lib/live'
export default async function Page() {
const { data } = await sanityFetch({
query: `*[_type == "post"]{ title, slug }`,
})
return <div>{/* render your content */}</div>
}If you absolutely need to continue using LiveQueryProvider with version 7.0.3, make sure:
'use client' at the top:// components/LiveQueryProviderWrapper.tsx
'use client'
import { LiveQueryProvider } from '@sanity/preview-kit'
export default function LiveQueryProviderWrapper({ children, client }) {
return (
<LiveQueryProvider client={client}>
{children}
</LiveQueryProvider>
)
}@sanity/preview-kit not next-sanity)However, I strongly recommend migrating to the modern Live Content API approach as it's designed specifically for Next.js 14's architecture, provides better performance, and is the actively maintained solution going forward.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store