-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to connect to overlays. Make sure you're calling the 'enableOverlays' function in '@sanity/overlays' correctly #671
Comments
Facing a similar issue in development as well while following the guide on [https://www.sanity.io/guides/nextjs-app-router-live-preview](the official sanity app router guide) |
Hey, what is the error in the console? This answer helps me. #556 (comment) |
Hey! Seeing the following error in the console: It is being used as follows: "use client";
import type { HistoryAdapterNavigate } from "@sanity/overlays";
import { useEffect, useRef, useState } from "react";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { enableOverlays } from "@sanity/overlays";
import { useLiveMode } from "@sanity/react-loader";
import { client } from "~/sanity/lib/client";
// Always enable stega in Live Mode
const stegaClient = client.withConfig({ stega: true });
export default function VisualEditing() {
const router = useRouter();
const routerRef = useRef(router);
const [navigate, setNavigate] = useState<
HistoryAdapterNavigate | undefined
>();
useEffect(() => {
routerRef.current = router;
}, [router]);
useEffect(() => {
const disable = enableOverlays({
history: {
subscribe: (navigate) => {
setNavigate(() => navigate);
return () => setNavigate(undefined);
}, Also just ran turbo clean:workspaces && turbo clean as per some suggestions in the linked comment but no luck unfortunately |
Check your session cookie, making sure that when clicking the
|
Can you confirm if this is still an issue using the latest packages, i.e. using |
confirmed this is still an issue |
any possible solution for this? |
This generally happens as a result of misconfiguration somewhere, essentially a connection between the application and Presentation tool is unable to be established. The code examples in this comment thread are outdated so it's very difficult to give feedback on what the specific problem might be. Our plan is to work on proactively detecting misconfiguration issues to provide better upfront warnings, until then it would be helpful if anyone seeing the same issue is able to share more context like framework, package version numbers, tool configuration, etc. Thanks. |
I'm currently working on a Next.js project and integrating Sanity with a presentation tool. However, I've encountered the following error: (PresentationTool-2QKQ3IHD.js?v=d3749efe:1359 Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly) I've thoroughly gone through the documentation related to @sanity/visual-editing, but I haven't been able to resolve the issue. Could you kindly provide guidance or point me in the right direction to fix this? |
I am trying to install Presentation tool to my hydrogen project. It works perfectly in the development mode. But there is no way to make it work in the production mode. I think it will be very neat to switch between an optimized production mode and an authorized mode to fetch draft content and edit. The error message is
PresentationTool-q3Ixv-a7-4a2ea8d5.js:95 Unable to connect to overlays. Make sure you're calling the 'enableOverlays' function in '@sanity/overlays' correctly
Here are the related code.
This is in production. The
Edit
button on the left cannot be toggled.The text was updated successfully, but these errors were encountered: