RethinkDB: Connecting Node.js to RethinkDB
This documentation is part of the Getting started guide. View the full guide here: Learn how to set up and secure your RethinkDB instance on Stackhero.
Welcome to the Stackhero documentation
Stackhero provides a ready-to-use RethinkDB cloud service designed for reliability and ease of use. You get:
- Seamless updates with a single click
- High performance and strong security on your own private, dedicated infrastructure
Get up and running fast: you can try Stackhero's RethinkDB cloud hosting in just a few minutes. Stackhero handles the setup and management, so you can focus on building your application.
Because connections to RethinkDB are secured with TLS, and the official RethinkDB client library does not support TLS, it is a good idea to use the rethinkdbdash library instead.
You can install rethinkdbdash with npm:
npm install rethinkdbdash
Here is a straightforward example showing how you can connect your Node.js application to your RethinkDB database. This setup includes server details like host and port, connection limits, and SSL settings.
const rethinkdbdash = require('rethinkdbdash');
const r = rethinkdbdash({
servers: [
{
host: '<XXXXXX>.stackhero-network.com',
port: 28015
}
],
ssl: true,
buffer: 20, // Minimum number of connections to keep open
max: 100, // Maximum number of connections
timeoutGb: 30 * 1000, // Time (ms) to keep unused connections
db: '<DATABASE>',
authKey: '<PASSWORD>',
// silent: true, // You can uncomment this line to suppress logging on stderr
});
Replace <XXXXXX>, <DATABASE>, and <PASSWORD> with your own values.
By following these steps, you will have your RethinkDB instance secured and ready to use on Stackhero. If you have any questions or need further guidance, you are welcome to reach out to our support team.