Connection
There are a couple ways to provide connection information to a client library.
Use projects. This is the recommended approach for local development. Once the project is initialized, all client libraries that are running inside the project directory can auto-discover the project-linked instance, no need for environment variables or hard-coded credentials. Follow the Using projects guide to get started.
Set the
EDGEDB_DSN
environment to a valid DSN (connection string). This is the recommended approach in production. A DSN is a connection URL of the formedgedb://user:pass@host:port/database
. For a guide to DSNs, see the DSN Specification.The value of
EDGEDB_DSN
can also be an instance name. You can create new instances manually with the edgedb instance create command.Explicitly pass a DSN or instance name into the client creation function:
edgedb.createClient
in JS,edgedb.create_client()
in Python, andedgedb.CreateClient
in Go.
```
const client = edgedb.createClient({
dsn: "edgedb://..."
});
```
Only use this approach in development; it isn’t recommended to include sensitive information hard-coded in your production source code. Use environment variables instead. Different languages, frameworks, cloud hosting providers, and container-based workflows each provide various mechanisms for setting environment variables.
These are the most common ways to connect to an instance, however EdgeDB supports several other options for advanced use cases. For a complete reference on connection configuration, see Reference > Connection Parameters.