Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat:hooks
  • Loading branch information
jcassidyav committed Oct 24, 2025
commit 3dd855ddb738ec0fb981b18b4cc3a25d3333dfaf
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@ To add hooks to your plugin, follow these steps:

**1. Install the Hook Module**

```bash
npm install nativescript-hook --save
```

For NativeScript 7+, use:

```bash
npm install @nativescript/hook --save
```
Expand All @@ -189,23 +183,15 @@ npm install @nativescript/hook --save
Create `postinstall.js` at the root folder of your plugin:

```javascript
var hook = require('nativescript-hook')(__dirname)
hook.postinstall()

// For NativeScript 7+:
// require('@nativescript/hook')(__dirname).postinstall();
require('@nativescript/hook')(__dirname).postinstall();
```

**3. Create preuninstall.js**

Create `preuninstall.js` at the root folder of your plugin:

```javascript
var hook = require('nativescript-hook')(__dirname)
hook.preuninstall()

// For NativeScript 7+:
// require('@nativescript/hook')(__dirname).preuninstall();
require('@nativescript/hook')(__dirname).preuninstall();
```

**4. Update package.json Scripts**
Expand Down Expand Up @@ -235,8 +221,7 @@ Define your hooks under the `nativescript` property:
},
{
"type": "after-prepare",
"script": "lib/after-prepare.js",
"inject": true
"script": "lib/after-prepare.js"
}
]
}
Expand All @@ -253,10 +238,6 @@ Specifies when the hook should execute. Format: `before-<hookName>` or `after-<h

The relative path from the plugin root to the hook implementation file.

#### inject (Optional)

Boolean property indicating whether the hook should be executed in-process (`true`) or spawned (`false`). When `inject: true`, the hook can access NativeScript CLI services.

#### name (Optional)

Custom name for the hook. Defaults to the plugin package name.
Expand Down
2 changes: 1 addition & 1 deletion content/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export default [
},
{
text: 'Hooks',
link: '/guide/nativescript-hooks-guide',
link: '/guide/hooks',
},
{
text: 'Platform Version Handling',
Expand Down
Loading