Is it possible that with payload cms i can fetch data like certain text a bit like in…
- User
Is it possible that with payload cms i can fetch data like certain text a bit like in i18n but like through payload for pages so that i customise the pages myself with react tailwind html etc. but i load like the translated text through payload or is this not really possible or smart with payload
Assistant
Yes, this is absolutely possible and actually a common pattern with Payload CMS! You can definitely use Payload as your content source for multilingual text while building custom pages with React/Tailwind.
Here are a few approaches you could take:
Option 1: Localized Collections Payload has built-in localization support. You can configure collections with multiple locales:
// In your Payload config { localization: { locales: ['en', 'es', 'fr'], defaultLocale: 'en', }, collections: [ { slug: 'page-content', fields: [ { name: 'pageKey', type: 'text', // e.g., 'homepage', 'about-us' }, { name: 'title', type: 'text', localized: true, }, { name: 'description', type: 'text', localized: true, } ] } ] }Option 2: Separate Language Collections Create separate collections for each language if you need more control:
// Collections like 'content-en', 'content-es', etc.Option 3: Single Collection with Language Field Store all translations in one collection with a language field.
Then in your React components, you'd fetch the content:
// Fetch from Payload API const response = await fetch(`/api/page-content?locale=${currentLocale}&where[pageKey][equals]=homepage`); const content = await response.json(); // Use in your component <h1 className="text-4xl font-bold">{content.docs[0].title}</h1>Benefits of this approach:
- Non-technical users can manage translations through Payload's admin UI
- Content is centralized and versionable
- You maintain full control over your frontend styling and structure
- Easy to add new languages without code changes
Considerations:
- Adds network requests for content (though you can cache/preload)
- Slightly more complex setup than static i18n files
- Depends on Payload being available
This pattern works really well for content-heavy sites where you want editorial control over translations while maintaining custom frontend experiences.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.