Hey everyone, Is there any way to integrate emails with Plasmic when client and server are in two different repos?
Hi, sorry I’m not sure I fully understand the question, but I’ll try to take a stab…You should be able to build emails with plasmic as long as you have the right set of code components, and to generate the emails you will need either a server-side API or just some node/js script that can perform the generation, check out this repo https://github.com/plasmicapp/plasmic/tree/master/examples/react-email
We are using Plasmic with codegen, so how do we get Plasmic instance in our server code? Is there any node-loader for plasmic?
So, one option is that your main plasmic project for your application does not need to be the same plasmic project for your emails. It probably is a good idea to keep them isolated from each other. For instance, a lot of the components that you would use in an application aren’t going to work or make sense in an email, and vice versa.
For the react-email application, that can just be a normal next JS application that uses the loader integration. This will keep things much simpler than using codegen. Then you can use the API endpoint or a node script to render the emails, as shown in that repo. You can then directly fire off those emails or put them into another mailing system as HTML.
Regarding whether there is a node loader, this is effectively what the current loader packages are, they are isomorphic and run in both client and server/node processes. So you can definitely just use them from a node script. Loader-react is the most plain package.
Let me know if that makes sense.