Since a single project can only have a single app host, it’s advisable to use the same host for all your projects. It’s also possible to use different hosts, just make sure all the components are imported in the main project’s host. This is to ensure that all code components in the imported project are available to the main project.
Nice to meet you! Seen your response posts around the forum and this is the first time we got a response from you! We are honored and grateful for the response
How does one add many plasmic projects to a plasmic init file so we can use the same host for all your projects?
I think I tried something like below once and unless I did something wrong it didn’t work.
projects: [
{
id: ID of the first project
token: API token of the first project
},
{
id2: ID of the second project
token2: API token of the second project
},
],
Thank you thank you We have a rotating schedule for support on the forum, so that’s probably why
Just so you know, the init file is not necessary for the code component registration at all.
The main requirement to get code components working with multiple projects is having the /plasmic-host that renders <PlasmicCanvasHost />. Then make sure code component registrations are there for all projects.
The init file is only necessary when you’re rendering the content. So in this case, you have a Style Tokens project and a Main project. If your Style Tokens project doesn’t have its own dedicated website, then the init file would only need the Main project’s ID/token.
I am an experienced Plasmic user and only grasp about 75% of what was said here; is there any way ya’ll can create some documentation/content around this? I have found this generally confusing and think its an area that is lacking in depth explanation.
@jason I have to agree with what @alyssa_feola said! Because I didn’t quite understand. I have a few clarification questions.
Don’t we have to import components into plasmic-init.ts?
Going back to your example above, so if the Style token project doesn’t need its own website, then we can add the Main project’s ID/token to use the same app host?
If this is the case, will the Style token project have its own project on Plasmic? (I want to have a Style token project on Plasmic that is different from the Main project) - kind of like the setup that Alyssa has.
Would you perhaps have an example to demonstrate how to use the same app host?
I was trying to explain that plasmic-init.ts is not relevant here, since that’s only for loading Plasmic content, whereas we’re just trying to register components to Plasmic.
I’ll post a few options here for registering components that hopefully make sense.
One app host (easy solution)
This works if you don’t have a dedicated site for your style tokens. You do NOT need the id/token for your style tokens project (though adding it doesn’t hurt, unless you have pages in the style tokens project that you don’t want to expose).
This is an example of using the single repo approach, correct?
So, say that was the repo that you had your components registered in, and you didn’t want to register every single component in the new project and just take them from there, would it be possible for you to create a new project that demonstrated how you’d leverage the registration that has already been done?
Unless I’m misunderstanding your question, you would just create a Plasmic project (without generating a new repo) and point to the existing repo’s app host.
No, I don’t think you were misunderstanding; that seems logical … I was just having a hard time getting there myself.
I think I was having a hard time rationalizing having a project on Plasmic with an App-Host without it being logically connected to a repo. It felt like that it would somehow be a phantom limb of some sorts.