Examples
Common patterns and examples for using react-toast-msg.
Here are some common usage patterns for react-toast-msg.
Form Submission
Show a success or error toast based on form submission results.
tsx1import { FormSyncForm } from "formsync";2import { toast } from "react-toast-msg";34export default function Example() {5 return (6 <main>7 <FormSyncForm8 formId="YOUR_FORM_ID"9 onSuccess={(res) => toast.success(res.message)}10 onSubmitError={(err) => toast.error(err.message)}11 >12 <input13 type="text"14 name="name"15 placeholder="Name"16 required17 />18 <button type="submit">19 Submit20 </button>21 </FormSyncForm>22 </main>23 );24}
Loading States (Manual)
While the library doesn't have a built-in promise handler yet, you can easily simulate it:
tsx1const handlePromise = async () => {2 // Show a default info toast3 toast("Processing...");45 const result = await myPromise();67 if (result.success) {8 toast.success("Completed!");9 } else {10 toast.error("Error occurred.");11 }12};
Custom Layouts
Since react-toast-msg is lightweight, you can use it alongside other UI components easily.
Check out the Playground for more interactive examples!
How is this guide?
Last updated on February 17, 2026