# WithReference

Term type: API method

Supplies a consuming resource with connection strings or service endpoint configuration from another resource.

Also known as: withReference, resource reference

`WithReference` in C# and `withReference` in TypeScript connect the configuration of resources. The information supplied depends on the referenced resource: a database can provide a connection string, while a service can provide named endpoints for service discovery.

A database reference typically becomes `ConnectionStrings__<name>` in the consuming process's environment. Service endpoint references supply service discovery configuration instead; a single reference does not necessarily provide both forms.

A reference does **not** guarantee startup order or readiness. Use an explicit wait when required, and configure the consuming application's client or service discovery support to read the supplied configuration.

## Practical example

Give an API a reference to a named PostgreSQL database to supply its connection string. Add WaitFor separately if startup must wait for readiness.

## Learn more

- [Connect your services with service discovery](https://aspire.dev/fundamentals/service-discovery/)

- [PostgreSQL hosting integration](https://aspire.dev/integrations/databases/postgres/postgres-host/)

## Related terms

- [Connection string](https://aspire.dev/hub/glossary/connection-string/)

- [Service discovery](https://aspire.dev/hub/glossary/service-discovery/)

- [WaitFor](https://aspire.dev/hub/glossary/waitfor/)