Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
When I load Stripe with Next.js and build error occurs

When I use Stripe in Next.js and "yarn build", I get an error.

During local development with yarn dev, it works without any error.

i cant understand why this is happen.

 function CheckoutForm(props) {
  const [redirect, setRedirect] = useState('true');
  const { bodyAdquire } = useAppContext();
  const router = useRouter();

  let teamName = process.env.NEXT_PUBLIC_TEAM_NAME

  let handleSubmit = async (event) => {
    event.preventDefault();


    const { stripe, elements } = props;
    if (!stripe || !elements) {
      return;
    }

    const card = elements.getElement(CardElement);
    let tokenId
    const result = await stripe.createToken(card);
    if (result.error) {
    } else {
      tokenId = result.token.id
    }

    
    const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY);
    const Checkout = () => {
      const {bodyAdquire} = useAppContext()
      return (
        <div className={Styles.App}>
          <div className={Styles.product}>
            <div>
              <Elements stripe={stripePromise}>
                <CheckoutForm tokens={bodyAdquire.tokens}/>
              </Elements>
            </div>
          </div>
        </div>
      );
    };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I solved it by removing the components that were not part of the page and leaving only the index file inside the next page. Make sure to move any non-pages out of the pages folder.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!