I'm hoping to get ideas/feedback for the best to structure a project I'm working on. It's a feedback widget that needs to be embeddable in other sites via a script tag, and I want the main app/dashboard/etc. to be a Next.js app. I do not want to use React for the widget because that makes the script too large. I'd also like to share UI styling as much as possible to avoid duplication.
So far my thoughts are to use a Turborepo like this:
app/web - Next.js app (landing pages/dashboard)
app/widget - Vite + Lit web-components app (feedback widget) (possibly just vanilla js if its easier somehow)
packages/ui - Tailwind-variants based framework-agnostic "components", i.e. just the class string outputs for things like button/input/etc.
This way I have each app running independently so I can configure them as needed. I can deploy app/web to my domain example.com and the widget script can be deployed to something like scripts.example.com/embed.js. And I can share styles between the two even though they're different frameworks.
Downsides are:
- This seems pretty complex, maybe theres a simpler solution?
- I'd like to be able to use some parts of the
app/widgetcomponents directly inside myapp/webapp, like on the customization preview page or as an example on the landing page. But this would mean importing an app inside an app which the docs say not to do. - Some style re-use between apps but not real component sharing.
Any feedback or ways to simplify/improve this?