Learn how the location of data stored in D1 is determined, including where the leader is placed and how you optimize that location based on your needs.
By default, D1 will automatically create your database in a location close to where you issued the request to create a database. In most cases this allows D1 to choose the optimal location for your database on your behalf.
Provide Location Hints
You may want to explicitly provide a location hint in cases where the majority of your writes to a specific database come from a different location than where you are creating the database from. Location hints can be useful when:
- Working in a distributed team.
- Creating databases specific to users in specific locations.
- Using continuous deployment (CD) or Infrastructure as Code (IaC) systems to programmatically create your databases.
Provide a Location Hint when creating a D1 database when:
wrangler d1to create a database.
- Creating a database via the Cloudflare dashboard.
To provide a location hint when creating a new database, pass the
--location flag with a valid location hint:
$ wrangler d1 create new-database --location=weur
Use the dashboard
To provide a location hint when creating a database via the dashboard:
- Log in to the Cloudflare dashboard and select your account.
- Go to Workers & Pages > D1.
- Select Create database.
- Provide a database name and an optional Location.
- Select Create to create your database.
The following location hints are currently supported:
|wnam||Western North America|
|enam||Eastern North America|