Since the app depends on both a database URL and Stripe API Keys, you will make sure you have both of them before deploying your app.
You need a MySQL database that will be reachable by the deployed application. Planetscale is the database host we used while developing this course, it provides a great developer experience and a generous free plan to try things around.
Once you have created an account, install Planetscale's command line and login.
pscale auth login
After logging in, create a new database and a default
pscale database create <DATABASE_NAME>
Finally generate database credentials with the
password create command. Replace
<DATABASE_NAME> with the name you used on the
<BRANCH_NAME> could be the default
main branch, and
<PASSWORD_NAME> is your password identifier since you can have many per database branch.
pscale password create <DATABASE_NAME> <BRANCH_NAME> <PASSWORD_NAME>
Keep the generated username, password and URL values handy because you will need them on the deploy step. Also head over to Planestcale's NextJs docs if you get stuck or want to learn more about how Planetscale works.
Up until this point you've been using Stripe's Test mode API Keys, but before you deploy your application you need to get Stripe live API Keys. Live mode is what you want before you launch your app, otherwise users won't be able to use their real accounts and cards.
Head over to your Stripe dashboard, on the API Keys section. Reveal your secret key and store it in a secure place since you'll need to set it up as environment variable on the hosting provider. Keep that small key safe! Learn about API Key and secrets management at the excellent Stripe API Keys docs.
You will also need to create a Webhook secret to handle order fulfilment, so head over to the Webhooks section of your dashboard and generate a secret there.
Select the Git repository you'd like to deploy from the dropdown list and click import to go to the "Configure project" step. In here you will setup your project name, framework preset which would be NextJs for this course, and root directory.
Vercel generally chooses great defaults for your project setup options, but you need to specify them for repositories with many projects like our OneWeekGraphQL repository which contains all chapters. Make sure to choose the correct chapter folder in the root directory input, and select NextJs as framework preset.
Make sure you add
STRIPE_WEBHOOK_SECRET on the environment variables section.
Once you've filled all configuration options, hit the big "Deploy" button to make vercel build your project and finally deploy it. Once it's done, you will have a production URL with your working project.