in Engineering


Introducing the Vercel Integration for SingleStore Helios

David Gomes

Director of Engineering

Introducing the Vercel Integration for SingleStore Helios

We're delighted to announce that a Singlestore Helios integration is now available on the Vercel Marketplace.

Vercel is a platform for hosting web applications, and it is a favorite among frontend developers due to its superb developer experience. With this new integration, it is now even easier for Vercel users to connect their applications to Singlestore Helios.

how-does-the-integration-workHow does the integration work?

The integration works by first asking users which Vercel account they'd like to integrate with a SingleStoreDB deployment. The account could either be a personal account or a Vercel team.

After reviewing the required permissions, users can either:

  • Create their very first SingleStoreDB workspace
  • Choose which one of their existing workspaces they'd like to connect to a specific Vercel project

Then, after clicking "Connect", our integration will setup three environment variables in the user's Vercel project:

  • SINGLESTORE_WORKSPACE_HOST
  • SINGLESTORE_WORKSPACE_USERNAME
  • SINGLESTORE_WORKSPACE_PASSWORD

Using these three variables, it is now possible to easily connect to SingleStoreDB from a Vercel function:

var SingleStoreClient = require('@singlestore/http-client');
var instance = SingleStoreClient.ApiClient.instance;
var BasicAuth = instance.authentications['BasicAuth'];
BasicAuth.username = process.env.SINGLESTORE_WORKSPACE_USERNAME;
BasicAuth.password = process.env.SINGLESTORE_WORKSPACE_PASSWORD;
instance.basePath = 'https://' + process.env.SINGLESTORE_WORKSPACE_HOST;
// Get the API handle.
var api = new SingleStoreClient.HttpApi();
export default function handler(req, res) {
api.rows(
{ queryInput: { database: 'mydatabase', sql: 'SELECT * FROM purchases LIMIT 200;' } }
).then(dbResponse => {
res.send(dbResponse.results[0].rows);
}).catch(err => {
res.send(err);
});
}

In the preceding example, we're using the SingleStore Data API to ensure that the query runs as fast as possible in a serverless environment such as Vercel functions.

Finally, we've put together a complete guide in our Docs for how to use the integration.

We welcome any feedback on the integration through our public Forums, and are looking forward to seeing what people build using this integration. More documentation is available on our Vercel marketplace listing.


Share