We've been informed by someone at Prismic that there is a way of connecting between repositories but I'm finding it difficult to find any concrete documentation on how to achieve this.
This is what we are trying to achieve:
- Global Repository which will house common content
- Scenario 1: Shared blogs common between all websites
- Scenario 2: Shared slices common between all websites
- Scenario 3: Shared images and media
- Many individual repositories with custom content but will also consume slices and content from the Global Repository
The tech stack we are running against is the latest version of NextJS and Slice Machine.
Is there any documentation (developer or blog) which would help achieve this?
Hi @damian.connolly,
If you run separate sections of your website with separate apps, this is quite easy. On the Prismic site, for example, we have two different Next.js apps connected to two different Prismic repositories: one for the main site and one for the documentation.
With a clean separation of concerns like this, there's no problem. If you're putting the same content on multiple websites, just be sure to use a canonical link to identify the main version.
This becomes much more complicated if you want to splice content from different repositories together on the same webpage. If that's what you're trying to do, I might recommend that you reconsider, as it could create a confusing experience for your content editors. Having said that, in principle it's quite easy to query content from multiple repositories on one page. Just initiate multiple clients:
const firstClient = prismic.createClient("repository-one")
const secondClient = prismic.createClient("repository-two")
const pageFromFirstRepository = await firstClient.getFirst()
const pageFromSecondRepository = await secondclient.getFirst()
Now, when you say "Many individual repositories with custom content but will also consume slices and content from the Global Repository", I suspect you want to create a connection between the repositories. Again, I don't recommend this approach, as it will likely be confusing for your editors. Having said that, in principle youcan achieve this with an integration field.
Sam
1 Like
Perfect, thanks for the information; this helped with the final bit I was missing.
Without going into much detail I completely understand and appreciate the concerns you raised.
It's not a feature we'd employ often but we have need for a Global Repository due to some content being exactly the same across most customer websites (e.g. articles). This approach means less maintenance for our content managers having to maintain many different versions of the exact same content and it's business critical to ensure it's maintained to the highest standard.
This means when one customer gets an update to the global content then they all get the exact same update across all websites. It's the trade-off for having a completely reusable solution with minimal maintenance from developers and content managers. The code is also being built in such a way that it's being configured defensively to mitigate the risks you mentioned.
1 Like
It sounds like you know what you're doing! Let me know if you have any other questions :)