Skip to content
On this page

๐Ÿž๏ธ @bridge/env

Utility module that provides access to environmental project data. View Source Code

import { ... } from '@bridge/env'

๐Ÿ’ผ Variables


The APP_VERSION holds the string value of the current bridge. version.

  • Type: string
console.log(`Current bridge Version: ${APP_VERSION}`)


The isNightlyBuild represents a boolean value to whether the user is on bridge. nightly or not.

  • Type: boolean
if (isNightlyBuild) {
	// Do something unique to nightly build, e.g. use a different color scheme

โšก Functions


This function returns the resolved path of the behavior pack in the user's current project.

  • Signature: getCurrentBP()
  • Returns: string
const bpPath = getCurrentBP()
// Can be used to read a file in the behavior pack
const file = await readFile(`${bpPath}/test.json`)


This function returns the resolved path of the resource pack in the user's current project.

  • Signature: getCurrentRP()
  • Returns: string
const rpPath = getCurrentRP()
// Can be used to read a file in the resource pack
const file = await readFile(`${rpPath}/test.json`)


The getCurrentProject function returns the path to the user's currently selected project folder.

  • Signature: getCurrentProject()
  • Returns: string
const projectName = getCurrentProject()
console.log(`Current Project: ${projectName}`)


This returns the project prefix (or namespace), from the project config, in the user's selected project.

  • Signature: getCurrentPrefix()
  • Returns: string | undefined
let itemName = 'minecraft:apple'
const projectPrefix = getProjectPrefix()

if (projectPrefix) itemName.replace('minecraft', projectPrefix)


The getProjectTargetVersion returns the set target version of the current project, for example "1.19.20".

  • Signature: getProjectTargetVersion()
  • Returns: string | undefined
const projectTargetVersion = getProjectTargetVersion()

// From 'compareVersions' from @bridge/compare-versions module
const isValid = compareVersions(projectTargetVersion, '1.18.0', '>=')


The getProjectAuthors function returns the authors of the current project. The return type can vary depending on the users config setup, so it could either be an array of string representing the names of the authors, or an array of objects with name and logo properties where name is the name of the author and logo is the path to an image that represents the author.

  • Signature: getProjectAuthors()
  • Returns: (string | { name: string; logo?: string })[] | undefined
let firstAuthor = 'Unknown'

const authors = getProjectAuthors()
if (authors[0]) {
	firstAuthor = authors[0].author ?? authors[0]


This function is essential for correctly accessing the paths of files in the user's project. It returns a resolved path based on the pack type id and path passed in. This will take into account the pack paths of the folder in the project config.

  • Signature: resolvePackPath(packId?: TPackTypeId, filePath?: string)
  • Returns: string
const entityFolder = resolvePackPath('resourcePack', 'entity')
const cowFile = resolvePackPath('behaviorPack', 'entities/cow.json')

const file = await readFile(cowFile)

Released under the GPL-3.0 License.