Skip to content
Branch: master
Find file History
styfle Publish Stable
 - @now/build-utils@1.1.1
 - now@16.6.3
 - now-client@6.0.0
 - @now/next@2.1.1
 - @now/node@1.2.1
 - @now/routing-utils@1.4.0
 - @now/static-build@0.13.1
Latest commit 75aefdd Dec 9, 2019

README.md

now client

Build Status Join the community on Spectrum

The official Node.js client for deploying to Now. It supports v1 and v2 deployments.

Usage

Firstly, install the package:

npm install now-client
# or
yarn add now-client

Next, load it:

// v2
const { createDeployment } = require('now-client');
// v1
const { createLegacyDeployment } = require('now-client');

Then call inside a for...of loop to follow the progress with the following arguments:

  • <path> - a directory path / file path / array of file paths (must be on the same level)
  • <options> - An object containing token, an optional teamId and any now.json-valid fields
async function deploy() {
  let deployment;

  for await (const event of createDeployment(
    '/Users/zeit-user/projects/front',
    { token: process.env.TOKEN }
  )) {
    if (event.type === 'ready') {
      deployment = event.payload;
      break;
    }
  }

  return deployment;
}

Full list of events:

[
  // File events (receive relevant data as payload)
  'hashes-calculated',
  'file-uploaded',
  'all-files-uploaded',
  // Deployment events (receive deployment object as payload)
  'created',
  'ready',
  'error',
  // Build events (receive build object as payload)
  'build-state-changed'
];

You can also get the events set programmatically:

import { EVENTS } from 'now-client';
You can’t perform that action at this time.