Bit can be used on pre-existing projects and components can be added using the
bit add command. If you would like to create new components we suggest you use the
bit create command.
Each component in a Bit workspace must have all its implementation files under the same directory. A component must have an entry file (
index.[ts|js] is used as the default.
To add your component to the workspace run the
bit add command followed by the namespace. The namespace is the the component folder structure you would like to see in your workspace.
Bit has mapped this component's files and registered them in the
.bitmap file. This enables Bit to treat a collection of files as a single unit, a component.
In addition to that, Bit has generated a component ID, with the pattern
<namespaces>/<component-name>. The component ID will be prefixed with the scope name once it has been exported to a remote scope (
You can use -n which is short for --namespace
To render your component - create a *.compositions.tsx
To add documentation to your component - create a *.docs.md
When you initialize Bit in a pre-existing project you can choose to use Bit to manage workspace dependencies or keep your current workflow.
bit install for workspace dependencies#
Bit manages all dependencies in
workspace.jsonc by default so it is recomended to move all dependnecies from
package.json to it. If you keep
workspace.json Bit will concat both files when running
bit install to manage dependencies in your workspace allows for several advanced dependency management features. For example, if some components require a different version of a dependency, Bit will automate the creation of workspaces (using either Yarn2 or PNPM). If you decide not to use Bit, this and similar features will not be supported.
You can keep using your current package manager for dependency management and keep all dependencies in your
package.json file. In this case, it is important to use
bit link after you install dependencies. This is because package managers often delete "unkown" files from
bit link re-creates all component-modules.
We recomend adding
bit link as a
post-install action on your
package.json file to simplify dev-experience.