1 、I followed this step:studio.plasmic.app → Code
2、modified src/App.tsx to:
import * as React from 'react';
import { PlasmicCanvasHost } from '@plasmicapp/loader-react';
import { BrowserRouter as Router, Routes, Route, Link } from 'react-router-dom';
import { PLASMIC } from './plasmic-init';
export default function AppRoot() {
return (
<Router>
<Routes>
{/* Your other routes... */}
<Route path="/plasmic-host" element={<PlasmicCanvasHost />} />
</Routes>
</Router>
);
}
3、plasmic-init.ts:
import { initPlasmicLoader } from "@plasmicapp/loader-react";
import { HelloWorld } from './components/HelloWorld';
export const PLASMIC = initPlasmicLoader({
projects: [
{
id: "62VSfAAG9cDdbzfti1bnc4", // ID of a project you are using
token: "23XjhNUyKQaDBfUYZcbo4cXLJUUWIIeQ3ifI0TJzDIpUsfntkxC2IHIq8FR9thbIhVzQPLmdOu9DYlPA7SOg" // 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.registerComponent(HelloWorld, {
name: 'HelloWorld',
props: {
verbose: 'boolean',
children: 'slot'
}
});
4、at http://localhost:3000/plasmic-host address seen:
5、but can’t found code components HelloWorld
By the way when I use Next.js mode, the result is:
the code component HelloWord can saw in it.