Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vercel/node

Package Overview
Dependencies
Maintainers
9
Versions
296
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/node

  • 3.2.17
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
603K
decreased by-1.84%
Maintainers
9
Weekly downloads
 
Created

What is @vercel/node?

@vercel/node is a serverless function runtime for Node.js, designed to be used with the Vercel platform. It allows developers to deploy serverless functions with ease, providing a seamless experience for building and deploying APIs, microservices, and other server-side logic.

What are @vercel/node's main functionalities?

Simple HTTP Endpoint

This feature allows you to create a simple HTTP endpoint that responds with 'Hello, world!'. It demonstrates how easy it is to set up a basic serverless function using @vercel/node.

const { createServer } = require('@vercel/node');

module.exports = (req, res) => {
  res.status(200).send('Hello, world!');
};

Handling Query Parameters

This feature shows how to handle query parameters in your serverless function. The example responds with a personalized greeting based on the 'name' query parameter.

const { createServer } = require('@vercel/node');

module.exports = (req, res) => {
  const { name = 'World' } = req.query;
  res.status(200).send(`Hello, ${name}!`);
};

Handling JSON Requests

This feature demonstrates how to handle JSON requests in a serverless function. The example processes a POST request with a JSON body and responds with a personalized message.

const { createServer } = require('@vercel/node');

module.exports = (req, res) => {
  if (req.method === 'POST') {
    let body = '';
    req.on('data', chunk => {
      body += chunk.toString();
    });
    req.on('end', () => {
      const data = JSON.parse(body);
      res.status(200).json({ message: `Hello, ${data.name}!` });
    });
  } else {
    res.status(405).send('Method Not Allowed');
  }
};

Other packages similar to @vercel/node

FAQs

Package last updated on 26 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc