ReactJS - Handle POST requests using react router dom

You can handle the POST request on your express server then redirect to a static page of your app :

app.post('/payment_webhook', (req, res) => {
    const paymentOk = req.body.payment // handle POST data
    if (paymentOk) {
        res.redirect('http://app.com/payment_success');
    } else {
        res.redirect('http://app.com/payment_failed');
    }
});

I get what you're after but you can't POST to the browser. If you're uncomfortable passing data as GET params in a URL, you could:

  1. store data in LocalStorage when user submits
  2. deliver server-rendered, static HTML upon redirect that contains purchase information
  3. asynchronously get user's purchase data upon page load with AJAX or fetch() (or your favorite data-grabbing util).

Since you're in a React world, I'd recommend the third option here. How to fetch data, build an API endpoint, store data, then display it goes well beyond the scope of this question so I'd suggest some Googling. Here's a starting point: https://code.tutsplus.com/tutorials/introduction-to-api-calls-with-react-and-axios--cms-21027