React
React
Stringtale is fully compatible with React as long as you’re using a back-end server to handle the communication with Stringtale. Currently we support NextJS (both the App router and the legacy pages router) as well as Express.js as back-ends, with more coming in the future.
Implementation
The implementation of Stringtale in React is very flexible. You’re not limited to just using plain text. It also supports string interpolation, formatting as well as custom components.
For all usages Stringtale uses FormatJS under the hood. So if you’re unsure about how to use it, please check out the FormatJS documentation.
Basic usage
In its most basic form Stringtale can be used anywhere you have static text that you want your clients to be able to edit. Here’s an example of how you can use Stringtale to change the text of a button.
The resulting output would be:
[Try now]
String interpolation
Stringtale isn’t limited to plain text. It also supports string interpolation.
The resulting output would be:
Your grocery list contains 3 items.
Using inline components
It’s also possible to use inline components in your strings. This can be useful when you want to use your own React components or links inside your strings.
The resulting output would be:
For our merchandise check out the store.
String interpolation and text formatting combined
String interlopation and text formatting combined can be used to create more complex strings.
Result 9 items.
Using standard HTML tags
To simplify the formatting of your strings, we’ve included an easy way to import standard HTML tags for you to use. They’re usage is slightly
different depending on wether it’s a self closing tag such as <br>
or not such as <b></b>
.
The resulting output would be:
This is a sentence with bold, italic and underlined text. It also has a linebreak
in the middle.