How to add custom File Actions to the Files app context menu in NC33?

Hi everyone!

I’m developing a custom app for Nextcloud 33 and I’m stuck on something that should be simple: adding a custom action to the Files app context menu (the 3-dot menu you see next to files).

What I want to achieve

Add a ā€œPrintā€¦ā€ entry to the context menu, similar to the built-in actions like:

- Download

- Rename

- Delete

- etc.

The print functionality itself works fine - I just need a way for users to trigger it from the Files interface.

What I’ve tried

I followed the official `@nextcloud/files` documentation and implemented it like this:

JavaScript/TypeScript:

```typescript

import { registerFileAction } from ā€˜@nextcloud/files’

const printAction = {

id: 'printserver-print',

displayName: () => 'Print',

iconSvgInline: () => '<svg>...</svg>',

enabled: ({ nodes }) => nodes.length === 1,

exec: async ({ nodes }) => {

    // Open print dialog

}

}

registerFileAction(printAction)

```

PHP side:

- Registered event listener for `LoadAdditionalScriptsEvent`

- Loading script with `Util::addInitScript()` for early execution

- Script loads successfully, no errors in console

The Problem

Everything *seems* to work:

- Script loads without errors

- `registerFileAction()` executes successfully

- My action appears in the `getFileActions()` registry (I can see it in the console)

- The print backend works when called directly

**
BUT:**

- The action never appears in the actual context menu

- The callbacks (`enabled()`, `displayName()`) are never invoked

Interesting observation

When I check `getFileActions()` in the browser console, I only see:

```javascript

[ā€˜contacts-import’, ā€˜printserver-print’]

```

But the context menu shows dozens of actions (Download, Rename, Delete, etc.) - none of which appear in this registry!

This makes me think: Is `@nextcloud/files` even the right API for the context menu?

I also tested with a .vcf file - the Contacts app uses the same `@nextcloud/files` API, but the ā€œImportā€ action doesn’t appear in the menu either.

My Questions

1. Is there a different API for the Files app context menu? Maybe a server-side registration or legacy system?

2. What is `@nextcloud/files` actually for? Viewer integrations? Inline actions? Something else?

3. Are there working examples of apps that successfully add actions to the Files context menu in NC33?

4. Should I consider an alternative approach? Like a button in the toolbar instead?

**
Environment**

- Nextcloud 33.0.2 (fresh test installation)

- @nextcloud/files 3.10.1

- PHP 8.2.32

- Tested on clean system with only my test app

What I’ve researched

- Read the official docs: https://nextcloud.github.io/nextcloud-files/

- Analyzed the Contacts app implementation

- Looked at core Files app code (`apps/files/src/actions/`)

- Tested 7 different registration approaches

- Confirmed early script loading works

I’m really stuck here and would appreciate any pointers! Has anyone successfully added custom actions to the Files app context menu recently?

Thanks in advance!

Nextcloud v33 uses @nextcloud/files 4..x not 3.x.

Also are you really trying this on 33.0.2? That’s 5 maintenance releases behind (33.0.7 is latest).

Current Status

Successfully upgraded from `@nextcloudnextcloud/files 3.10.1` → `4.0.0`

Build successful with updated API

FileAction not appearing in context menu

What we changed

1. package.json

`@nextcloud`json

ā€œ@nextcloud/filesā€: ā€œ^4.0.0ā€

```

2. Breaking API Changes Applied

OLD (3.x):

```typescript

import { registerFileAction, F@nextcloudleAction } from ā€˜@nextcloud/files’

const action = new FileAction({

id: 'printserver-print',

displayName: () => 'Print...',

// ...

})

registerFileAction(action)

```

NEW (4.x):

```typescript

import { registerFileAction, type FileAct@nextcloudonData, type View } from ā€˜@nextcloud/files’

const action: FileActionData = {

id: 'printserver-print',

displayName: (files: Node\[\], view: View) => 'Print...',

iconSvgInline: (files: Node\[\], view: View) => printSvg,

enabled: (files: Node\[\], view: View) => true, // DEBUG: always true

exec: async (file: Node, view: View, dir: string) => {

    // ... open dialog

    return null

},

order: 50,

}

registerFileAction(action)

```

The Problem

Browser console shows:

```

PRINTSERVER: [AT LOAD] All actions: Array [ ā€œcontacts-importā€, ā€œprintserver-printā€ ]

```

Action IS registered in the global action registry

BUT:

- `enabled()` callback is NEVER called (confirmed with console.log)

- Action does NOT appear in file context menu (3-dot menu or right-click)

What we’ve tried

1. Cleared NextCloud cache (`occ maintenance:repair`)

2. Hard browser reload (Ctrl+F5)

3. Verified all function signatures match TypeScript definitions

4. Added debug logging to `enabled()` - never triggers

5. Set `enabled: () => true` to always show - still nothing

Question

Is there additional conf@nextcloudguration needed for FileActions in @nextcloud/files 4.x?

Possible missing properties:

- `inline?: () => JSX.Element`

- `default?: boolean`

- View-specific registration?

The old 3.x code worked perfectly. Same logic with 4.x API signatures doesn’t show the action in U@nextcloud.

Environment:@nextcloud

- NextCloud: 33.0.2

- @nextcloud/files: 4.0.0

- @nextcloud/vue: 9.5.0

- Node.js: 24.19.0

Any guidance appreciated!