Configuration (partykit.json)
This is a reference of all the fields you can add to your partykit.json
file to configure the behavior of your project.
Project configuration
name
The name of your project. This is used to identify your project on the platform, and is also used to generate the url for your project (typically https://<name>.<user>.partykit.dev
) For example:
Alternately, you can pass this as an argument to the dev
or deploy
commands, like this: npx partykit dev --name my-project
main
The entry point for your project. This is where you’d define a default export as specified by the PartyKit API. For example:
parties
In addition to the main entry point, each PartyKit project can host multiple independent parties:
Related guide: Using multiple parties per project
serve
Serve static assets or a static website from the root of your your PartyKit project
Related guide: Serving static assets
vars
A list of environment variables that you want to set for your project. These are available on the room
object as room.env
. Example:
Dev server configuration
port
The port to use when you start the dev server using partykit dev
. Defaults to 1999
.
persist
Path to persist the party storage to in development mode. Defaults to .partykit/state
.
Set to false
if you don’t want to persist storage between dev server restarts.
With a configuration like that, you could then access the variable in your code like this:
Related guide: Managing environment variables in PartyKit
Build configuration
build
Occasionally, you’ll want to run some custom commands before running the server, as well as when you make changes to your code, and finally before you deploy your code on to the platform. You can define those commands here with an object that has the following properties:
- command: The command to run.
- watch: A directory to watch for changes. If any files in this directory change, the command will be run again.
- cwd: The directory to run the command in. Defaults to the directory of your
partykit.json
file.
So for example, a build
object that runs npm run build
and watches the src
directory would look like this:
define
A list of constants that you want to set for your project. Any globals with these names will be substituted with the values you provide here. For example:
With a configuration like that, you could then access the variable in your code like this:
minify
Whether to minify the JavaScript build output before deploying. Defaults to true
.
Runtime configuration
compatibilityDate
Cloudflare Workers API Compatibility date to use.
compatibilityFlags
Additional Cloudflare Workers API Compatibility flags to use.