Skip to content

The PlanetScale serverless driver for JavaScript

Learn about the PlanetScale serverless driver for JavaScript.

Overview

This article will cover how to enable the PlanetScale serverless driver for JavaScript and why you'd want to use it for your projects.

Why use the PlanetScale serverless driver for JavaScript

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 & 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.

Enable a database for the serverless driver

In order to use the PlanetScale serverless driver for JavaScript, the feature must be enabled on the database level. By enabling the feature, new credentials created by PlanetScale will have a different hostname that is enabled for HTTP access. The feature is currently in beta, and enabling the feature does not impact existing credentials that are currently in use.

You can find the option to enable the feature under "Settings" > "Beta features". Click "Enroll" to enable the feature.

The location in the PlanetScale dashboard where the driver can be enabled.The location in the PlanetScale dashboard where the driver can be enabled.

Once the feature is enabled, you’ll need to generate a new set of credentials to use the driver. You may do this by navigating to "Settings" > "Password" and clicking "New password".

How to create a new password in the PlanetScale dashboard.How to create a new password in the PlanetScale dashboard.

Give the password a name and click "Generate password".

The New password modal.The New password modal.

The new credentials that will be generated should have a hostname like <REGION>.connect.psdb.cloud.

The New password modal after the password has been created.The New password modal after the password has been created.

Need help?

Get help from the PlanetScale support team, or join our GitHub discussion board to see how others are using PlanetScale.

Was this page useful?
Last updated on August 18, 2022
Help us improve this page
© 2022 PlanetScale Inc.