nuxt-run

Bundle server run scripts into standalone mjs entries during the Nuxt/Nitro build
31,996 4
Install
npm install nuxt-run
Latest Version:1.2.0
Vue:3
License:MIT
Last Updated:Jul 29, 2026
Links: GitHub  ·  npm
Maintainer: aidanhibbard

nuxt-run

npm version npm downloads License Nuxt

Sponsored by


Runnable scripts in any environment.

Useful when you need to:

  • Run service code against an environment without pulling secrets down
  • Avoid HTTP endpoints just to trigger server code
  • Skip a queue when a one-shot or cron script is enough

Getting started

npm install -D nuxt-run
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-run'],
  run: {
    runDir: 'server/run',
    runPattern: '**/index.{ts,js,mjs}',
  },
})

Add a script under server/run/<name>/index.ts:

// server/run/seed/index.ts
const {
  database: {
    url,
  },
} = useRuntimeConfig()

const orm = new MyOrm(url)

const seed = async () => {
  await orm.insert(...)
}

seed().catch((e) => {
  console.error(e)
  process.exit(1)
})

In dev:

nuxt dev
node .nuxt/dev/run/seed/index.mjs

Post build:

nuxt build
node .output/server/run/seed/index.mjs

Scripts share Nitro's module graph, so useRuntimeConfig() and server/utils work.

More detail: Getting started.

Contribution

npm install
npm run dev:prepare   # generate type stubs
npm run dev            # develop with the playground
npm run dev:build      # production build of the playground
npm run lint
npm run test
npm run vp:dev         # VitePress docs site
npm run release

Version History

Version Released License
1.2.0 MIT
1.1.0 MIT
1.0.0 MIT