r/webdev • u/joxters • Oct 16 '26
Question Many sites with same components
Hello!
I am working with a company that has many, many sites. And the way we used to do components, we hard-coded every single one in every single project. This naturally has led to some inconsistency between sites when they’re supposed to look pretty identical.
Php include has become our life blood to mitigate some of these issues, but it still persists. The benefit, though, is that with php include, our sites automatically update when the “single source of truth” does.
My company wants to move to something more modern/popular and I got tasked with playing with frameworks. Think React, Next. My boss wants to replicate php include on these. I’ve spent the last several weeks looking into module federation, micro front-ends, anything to at least somewhat replace php include, but to no avail. That requires completely changing our server, which we do not have the ability to (as far as I know). These also sound like a nightmare to maintain, and our team is very small.
SEO is also a huge concern. I have module federation working on client side rendering, but ideally search engines would be able to index our work and, correct me if I’m wrong, but I don’t think client side rendered stuff is?
So now we’re stuck. I’ve suggested a monorepo, but with the amount of websites we have, the other developers worry about build times.
Believe it or not this is actually my first real-deal developer job haha, and I’m already stuck trying to fit a square peg in a round hole. So forgive me for any mistakes or misinformation, I’m still a junior trying to figure this out haha.
View all comments
2
u/shgysk8zer0 full-stack Oct 20 '26
So, it largely depends on exactly how you're defining components here, because full components would be fully encapsulated and agnostic about the rest of the site. There's also the question of functionality and customization and if this is only client-side.
My preferred method is publishing web components (
customElements.define()on npm or a CDN with a shared color palette/custom properties and other styles usingexport default new CSSStyleSheet().replace()). Customize via<slot name="...">andpart="..."and such. But all those details are a bit much for a Reddit comment.If you're wanting PHP include style things, honestly... Just creating a repo to use as a submodule is probably the easiest thing in my experience... Just remember changes will be made in the original repo. So you'd keep your current methods, but the paths would change to
submodule/component.phtmlor whatever.Each ecosystem would have it's own method that probably involves publishing on npm or something. I just prefer the web components because they're just web standards and can be used in React & Angular and any PHP, etc. Plus they provide encapsulation, so you don't have to worry about some
.whateverstyles creating conflicts, but you can use::part(foo) {color:red;}.Another option is HTML sharing HTML, maybe via a submodule, and using...