Alert This post is over a year old, some of this information may be out of date.

#DevHack: Specifying what to run on Vercel dev

While developing the integration with Strava on our cycling club website, I wanted to use serverless functions to simplify the data retrieval from Strava. The website runs on Vercel, and if you’re going to test out your serverless functions locally, you will need to use Vercel its CLI.

You can install the Vercel CLI by running the following command: npm i vercel -g.

Installing the Vercel CLI
Installing the Vercel CLI

Once installed, login with the vercel login command and provide your email address, which you use for Vercel.

Logging in to Vercel
Logging in to Vercel

Once logged in, you can run the vercel dev command. If it is the first time for your repository, the CLI will ask you a couple of questions to connect your project.

Linking the project
Linking the project

When you provided all this information, the Vercel CLI retrieves this command’s configuration from their website.

When you want to change which scripts you want to run when initiating vercel dev, you will have to configure it in your project settings:

  • Go to your Vercel dashboard
  • Select the project
  • Go to the project settings page
  • Overwrite the development command under the “Build & Development Settings”

In my case, I changed this to npm run start:dev.

Configuring the build and development commands
Configuring the build and development commands

When running vercel dev, you will see it retrieves your config, and runs the specified command.

Running the vercel dev command
Running the vercel dev command

It is pretty neat that all of this can be configured from within their site. Great when you work within a team, and you all use the same configuration. Initially, I tried to configure this from the package.json scripts, where many others do this.

Happy developing

Comments

Back to top