Create an App

You can create a NodeJS app using our official Node app type:

$bit
Copiedcopy

Run the app using the following command:

$bit
Copiedcopy

Your application will now be executed and echo "hello world!".

You can control your Bit app configuration from the *.bit-app.ts in your component. The Bit app can also be added to existing components to get them to expose an app:

// my-app.bit-app.ts
import { NodeApp } from '@bitdev/node.node-app';

export default NodeApp.from({
  name: 'my-app',
  mainPath: import.meta.resolve('./my-app.js'),
});
CopiedCopy

Head here to learn the options for our official NodeJS app type accepts. Alternatively, create an basic Bit app and integrate the tooling yourself.

Build

The Node app default build uses ESBuild. To build the app use:

bit build my-app
CopiedCopy

If using Ripple CI, simply snap and export your components. Build artifacts can be found on the directory the bit build command will output.

├── my-app.cjs
CopiedCopy

You can now use node to simply run your app:

node /path/to/output/my-app.cjs
CopiedCopy

Deploy

You can add your own deployment function to deploy the asset anywhere you like:

export async function deploy(context: AppDeployContext) {
  const artifact = context.findByName('app-bundle');

  const path = artifact.artifactDir;
  const url = execSync(`deploy ${path}`).toString('utf-8');
  
  return {
    url
  };
}
CopiedCopy

Use the deploy functon to execute commands and use APIs to deploy your app. Learn more on deploying Bit apps.