## useStripe hook

The `useStripe` hook returns the initialized [Stripe.js](https://docs.stripe.com/js/initializing.md) instance from the `Elements` provider. Use it to [confirm payments](https://docs.stripe.com/js/payment_intents/confirm_payment.md) and call other Stripe.js methods from inside your React components. If you need to access the Stripe object from a class component, use [ElementsConsumer](https://docs.stripe.com/js/react_stripe_js/elements/elements_consumer.md) instead.

### Return value

* `result` Returns the `Stripe` instance configured on the [provider](https://docs.stripe.com/js/elements/elements_provider.md), or `null` while it is still loading.

### Example

```jsx
import React from 'react';
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
import { useStripe } from '@stripe/react-stripe-js';

const stripePromise = loadStripe('pk_test_...');

function MyComponent() {
  const stripe = useStripe();

  const handlePayment = async () => {
    if (stripe) {
      // Use Stripe.js to confirm the payment
      const { paymentIntent, error } = await stripe.confirmPayment({
        elements, // The Elements instance that was used to create the Payment Element
        confirmParams: {
          return_url: 'https://your-website.com/success',
        },
      });
      // Handle the payment confirmation result
    }
  };

  return (
    <Elements stripe={stripePromise}>
      {/* ... other components */}
      <button onClick={handlePayment}>Pay</button>
    </Elements>
  );
}
```