I am building an online takeout ordering system for my client that will integrate with their Square POS via the Square Orders/Customers/Payment/Loyalty APIs, using NextJS front end and either Firebase or AWS Cognito for backend auth, to allow customers to re-order previous items from order history and maintain their loyalty points.
My question is where to initialize the Square Client in a NextJS application? in the /API routes, in getServerSideProps, or init in a separate util file that is imported into getServerSideProps?
Thank you for any advice!