I have a project in Plasmic with next.js. I used your guides to create a global context and a custom component. I cannot see any errors and I cannot see my custom component or global context in the Studio.
Here are extracts from the project:
src/context/PlasmicGlobalContext.tsx
import { DataProvider, GlobalActionsProvider } from '@plasmicapp/loader-nextjs';
import { PropsWithChildren, useMemo } from 'react';
export function PlasmicGlobalContext({ children }: PropsWithChildren) {
const actions = useMemo(() => {
return {};
}, []);
return <GlobalActionsProvider contextName="PlasmicGlobalContext" actions={actions}>
<DataProvider name="global" data={{ test: 1 }}>
{children}
</DataProvider>
</GlobalActionsProvider>;
}
src/plasmic-init.ts
import { initPlasmicLoader } from '@plasmicapp/loader-nextjs/react-server-conditional';
import { PlasmicGlobalContext } from './context/PlasmicGlobalContext';
export const PLASMIC = initPlasmicLoader({
projects: [
{
id: 'sitWCCBXbJ1DALqodCF93E', // ID of a project you are using
token: 'CrPPNDlsvIP8u6sNjH2FzJ1szliK4e2T19lBB6K9O4iT7b2DjSrBKDK5weAXkE8nctO1tr1NFsgHJQSucA', // API token for that project
},
],
// Fetches the latest revisions, whether or not they were unpublished!
// Disable for production to ensure you render only published changes.
preview: true,
});
PLASMIC.registerGlobalContext(PlasmicGlobalContext, {
name: 'PlasmicGlobalContext',
props: {},
providesData: true,
globalActions: {},
});
src/plasmic-init-client.ts
'use client';
import { PlasmicRootProvider } from '@plasmicapp/loader-nextjs';
import { PLASMIC } from './plasmic-init';
import { HelloWorld } from './components/HelloWorld';
PLASMIC.registerComponent(HelloWorld, {
name: 'HelloWorld',
props: {
verbose: 'boolean',
children: 'slot',
},
});
export function ClientPlasmicRootProvider(props: Omit<React.ComponentProps<typeof PlasmicRootProvider>, 'loader'>) {
return <PlasmicRootProvider loader={PLASMIC} {...props}></PlasmicRootProvider>;
}
I also tried to create one more project via `create-plasmic-app` to automate the process and avoid manual mistakes - the same, result