Registry / database / i18next-node-mongodb-backend-next

i18next-node-mongodb-backend-next

JSON →
library1.0.3jsnpmunverified

i18next backend that loads translation resources from a MongoDB database using the official Node.js MongoDB driver (v3.5+). Version 1.0.3 requires MongoDB driver to be installed separately (no bundling). Renamed from i18next-node-mongo-backend due to NPM account loss. Offers multiple connection methods: URI, host/port, or custom MongoClient instance. Supports custom collection, language, namespace, and data field names. Includes sanitization of special characters. Release cadence is low (last update 2022).

npm install i18next-node-mongodb-backend-next
INSTALL
IMPORT
SIG · I18NEXT-NODE-MONGO
I
i18next-node-mongodb-backend-next
databasejavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Backend
import Backend from 'i18next-node-mongodb-backend-next'
const Backend = require('i18next-node-mongodb-backend-next').default
Default export; CJS require works via module.exports, but .default is incorrect.
default
const Backend = require('i18next-node-mongodb-backend-next')
import { Backend } from 'i18next-node-mongodb-backend-next'
Named import does not exist; only a default export is provided.
MongoDBBackend
import Backend from 'i18next-node-mongodb-backend-next'; // No named export, use default
import { MongoDBBackend } from 'i18next-node-mongodb-backend-next'
There is no such named export; the backend is the default export.

Initialize i18next with MongoDB backend using a pre-existing MongoClient instance.

import i18next from 'i18next'; import Backend from 'i18next-node-mongodb-backend-next'; import { MongoClient } from 'mongodb'; const client = new MongoClient('mongodb://localhost:27017', { useUnifiedTopology: true }); await client.connect(); i18next.use(Backend).init({ backend: { client, dbName: 'i18ndb', collectionName: 'translations', languageFieldName: 'lang', namespaceFieldName: 'ns', dataFieldName: 'data', }, fallbackLng: 'en', preload: ['en', 'de'], }).then(() => { console.log(i18next.t('key')); });
Debug
Known issues
gotchaRequires installing 'mongodb' as a separate dependency; not included.
fix
Run 'npm install mongodb i18next-node-mongodb-backend-next' or 'yarn add mongodb i18next-node-mongodb-backend-next'.
affects: >=1.0.0
deprecatedPackage is renamed from 'i18next-node-mongo-backend' and original npm account lost.
fix
Use this package instead; update references in package.json and imports.
affects: >=1.0.0
gotchaThe 'dbName' field is required in backend options even when using a MongoClient that already specifies a database.
fix
Always provide 'dbName' in backend options.
affects: >=1.0.0
gotchaIf both 'user' and 'username' are provided, behaviour is undefined; only one should be set.
fix
Use only 'username' (or 'user') in backend options.
affects: >=1.0.1
gotchaMongoDB special character sanitization can rename fields unexpectedly if enabled (default: true).
fix
Set 'sanitizeFieldNameCharacter: false' if you need literal field names with dots or dollar signs.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Backend option 'dbName' is required.
Missing 'dbName' in backend options object.
fix
Add 'dbName: "yourDatabaseName"' to the backend options when initializing i18next.
Cannot find module 'mongodb'
MongoDB driver not installed as a dependency.
fix
Run 'npm install mongodb' or 'yarn add mongodb' in your project.
MongoNetworkError: failed to connect to server [localhost:27017] on first connect
MongoDB not running or connection URI incorrect.
fix
Start MongoDB or check the URI/host/port and authentication credentials.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
mongodbrequiredPeer dependency – the library uses the official MongoDB driver but does not bundle it.
Agent activity
6 hits · last 30 days
node
6
Resources
i18next-node-mongodb-backend-next — npm install i18next-node-mongodb-backend-next · libregistry