Hi, Shane! Welcome to the Vercel Community 😄
You could structure your JSON data with explicit fields, like so:
1{2 "text": "Hello World",3 "className": "text-blue-500"4}
Then create React components that accept the structured data as props, render the content with appropriate HTML elements and apply classes or styles as needed.
Then when it comes to parsing and rendering the content, it'd look like:
1// Read JSON normally2const data = await readJsonFile()34// Render through your component5<StyledText content={data} />
This would make sure that:
- ✅ Type-safe and secure
- ✅ No raw HTML injection
- ✅ Full React component control
- ✅ Easy to maintain and extend
This is safer than using dangerouslySetInnerHTML while still achieving styled, structured content from your JSON files.