Display messages or redirect based on responses
Trigger actions as soon as the user rates:
1const { review } = useProofConvert();
2
3const handleCheckout = () => {
4 review('checkout-flow', {
5 onRate: (data) => {
6 // 5 stars? đ
7 if (data.rating >= 5) confetti();
8
9 // 1-2 stars? đŦ
10 if (data.rating <= 2) openSupport();
11 },
12 onSubmit: () => {
13 // Redirect after they are done
14 router.push('/order-confirmed');
15 }
16 });
17};You can also await the result if you prefer linear logic:
1const handleAction = async () => {
2 // Wait for the user to finish the entire flow
3 const result = await review('new-feature');
4
5 if (result.completed) {
6 console.log("User finished!", result.rating);
7 toast.success("Thanks for your feedback!");
8 } else {
9 console.log("User closed the widget");
10 }
11};