psql or any
standard Postgres driver. Your applications connect to a Neki router instead
of connecting to each shard’s primary or replicas. The router plans each statement and sends it to
the required Postgres shards.
Create a role for each application or permission boundary. The same role can
be reused by that application’s connection pool and other connections that
need the same permissions.
Get connection details
- Dashboard
- CLI
1
Open the database in the PlanetScale dashboard and click Connect.
2
Optionally, select the branch you want to connect to.
3
Select an existing role, or create a user-defined role with the permissions your application needs.
4
Under Connection target, choose a router group. The
default
router group is selected by default.5
To send queries to read-only replicas, select Route queries to a
replica. This option is separate from the router-group target.
6
Select your framework, language, or Postgres CLI, then copy the generated connection details.
psql command has this form:postgres logical database within a cluster.Connection parameters
All connections to Neki databases use port
5432.
Secure connections
Neki requires TLS. Your client should verify both the certificate chain and the server hostname instead of only encrypting the connection. The generatedpsql command uses sslmode=verify-full and the system CA store.
Other drivers use different names for the same settings. Select your framework
or language on the Connect page to get the correct TLS configuration for
that client.
Private connections
Keep traffic between your cloud network and Neki off the public internet with AWS PrivateLink or GCP Private Service Connect. Private connections use the same roles, router groups, and required TLS settings as public connections.Primary and replica routing
By default, Neki sends work to shard primaries. Use that for writes and for reads that need the latest committed data. Set__neki.target to send reads to replicas.
Selecting Route queries to a replica on the Connect page adds this
setting to the generated connection options. It does not change the username.
psql, use PGOPTIONS:
options parameter:
pscale shell, add --replica. That sets __neki.target=REPLICA for the session.
See Choosing where reads run for Neki’s replica selection settings and lag behavior.

