The solution is different for NextJS page router vs app router.
If it is server component, every canvas component has context
property, that has searchParams
, which then you can pass into isIncontextEditingEnabled
. For example:
You can use NextJS preview value, because Uniform Canvas is rendering the site via the preview mode:
https://nextjs.org/docs/pages/building-your-application/configuring/preview-mode
Please note that preview may be 'true' even outside Uniform Canvas, if you pass the preview NextJS cookies. For example, in Vercel. If you want to execute the code only in Uniform, use the example below:
Another example for use in a component: