Create apps

An app is a component that can be served, built and deployed. Naturally, apps have dependencies (components and packages) but no dependents. For example, the todomvc/app component is an app. It uses todomvc/header and todomvc/footer, two standard Bit components, as a dependencies:

Run an app locally

Run the following to list all available apps in your workspace:

$bit
Copiedcopy

The output lists the IDs of the available app components and their corresponding app names:

┌──────────────────────────┬──────────────┐
idname
├──────────────────────────┼──────────────┤
learnbit-vue.todomvc/apptodomvc-app
└──────────────────────────┴──────────────┘

Run the following to run an app locally, independent of Bit's dev server:

$bit
Copiedcopy

The output is similar the following (open the listed path and port in your browser, to explore your app):

todomvc-app app is running on http://localhost:3000

Create a new app component

Run the following to create an app using your env's component generator:

$bit
Copiedcopy

The output displays the ID of the generated app (component):

1 component(s) were created

my-org.my-scope/apps/todo
location: my-scope/apps/my-vue-app
env: bitdev.vue/vue-env (set by template)

The generated app component includes an app plugin file, my-app.vue-app.cjs, with a file extension that is detected by its corresponding application-type - in this case, the Vue app-type. Use a different plugin file to switch from Bit's official Vue app-type, to a different app-type. This will affect how your app is being served, built and deployed.

my-scope/apps/my-app
static
static/index.html
index.html
index.ts
index.ts
my-app.docs.md
my-app.docs.md
my-app.root.ts
my-app.root.ts
my-app.spec.ts
my-app.spec.ts
my-app.vue
my-app.vue
my-app.vue-app.cjs
my-app.vue-app.cjs

Note that the app plugin file my-app.vue-app.cjs is not in ES Module but CommonJS format since this file need to be run directly in Node runtime.

Run the following using the app's component ID to make this app loadable by your workspace:

$bit
Copiedcopy

Define an existing component as an app

To define an existing component as an app, add to its directory an app plugin file. Note that the specific file extension of a plugin file determines its application type. For example, the following .vue-app.cjs file extension is loaded by Bit's official Vue application type.

// my-app.vue-app.cjs

module.exports = {
  name: 'my-app',
  /* provide your bundler with an app entry file */
  entry: [require.resolve('./my-app.app-root')],
};
CopiedCopy

To make this app loadable by your workspace, run the following:

$bit
Copiedcopy

Fork Vue apps

Search bit.cloud for Vue apps. Fork app components to get started quicker, with apps that already have much of the setup you need.

For example, run the following to fork the TodoMVC app to your workspace:

$bit
Copiedcopy

Run the following to make the forked app loadable by your workspace:

$bit
Copiedcopy