The `nextcloud-node-client` is a TypeScript-first library offering a comprehensive API to interact with Nextcloud servers from Node.js applications. Currently at version 1.8.1, it demonstrates an active development cadence with regular minor releases introducing new features like recursive file retrieval, user management, and improved sharing capabilities. The library differentiates itself by providing a rich, simple API that abstracts away the underlying Nextcloud communication protocols, supporting essential operations such as uploading and downloading files, managing folder structures, handling user accounts, creating and managing shares, and applying tags and comments to filesystem elements. A key feature is its flexible credential management, allowing configuration via environment variables (NEXTCLOUD_USERNAME, NEXTCLOUD_PASSWORD, NEXTCLOUD_URL) or Cloud Foundry's `VCAP_SERVICES`, and strongly recommending the use of Nextcloud's app-specific passwords for enhanced security. This client aims to streamline automation tasks for Nextcloud instances.
npm install nextcloud-node-clientVerified import paths — ran on the pinned version, not inferred.
This example demonstrates creating a Nextcloud client, managing folders and files, adding tags, retrieving file content, and creating password-protected public shares, followed by cleanup. It uses environment variables for authentication.
Use the base Nextcloud server URL for `NEXTCLOUD_URL`. If experiencing connection issues, verify Nextcloud's WebDAV API is functioning correctly on your server by attempting to access it directly via a browser or a WebDAV client.
Generate an app-specific password in your Nextcloud security settings and use it for `NEXTCLOUD_PASSWORD` in your environment variables or client configuration.
Structure your code using `async` functions and `await` keywords for all operations that return a Promise. Implement robust `try...catch` blocks to handle potential API errors.
Switch to ESM import syntax: `import Client, { File } from 'nextcloud-node-client';`. Ensure your project is configured for ESM or use a bundler if targeting older Node.js environments.Set the `NEXTCLOUD_USERNAME`, `NEXTCLOUD_PASSWORD`, and `NEXTCLOUD_URL` environment variables before running your application, or pass them directly to the `Client` constructor: `new Client({ url: '...', username: '...', password: '...' })`.Verify that `NEXTCLOUD_USERNAME` and `NEXTCLOUD_PASSWORD` (preferably an app-specific password) are correct. Ensure the Nextcloud user has the necessary permissions for the attempted operations. Check your Nextcloud server's `config/config.php` to ensure the `trusted_domains` array includes the domain or IP of your Node.js application.
No dependency data recorded yet.