Why use the PlanetScale serverless driver
Before learning how to use the PlanetScale serverless driver for JavaScript, it’s worth understanding why you should use this over other MySQL packages available in the directory. Some serverless and edge function hosts do not permit arbitrary outbound TCP connections, which is how many MySQL clients operate. Using the PlanetScale serverless driver for JavaScript provides a means of accessing your database and executing queries over an HTTP connection, which is generally not blocked by cloud providers. If you encounter issues using MySQL packages with PlanetScale, use the serverless driver instead.NoteBe sure to check out our F1 Championship Stats demo application to find examples for use with Cloudflare Workers, Vercel Edge Functions, and Netlify Edge Functions.
Add and use the PlanetScale serverless driver for JavaScript to your project
To install the package in your project, run the following install command:Connect to the database
The first step to using the PlanetScale serverless driver for JavaScript is to connect to your database. You can get your connection string in the PlanetScale dashboard by clicking on your database, clicking “Connect”, and selectingdatabase-js from the “Select your language or framework” section.

