Skip to main content
Config plugins are JavaScript or TypeScript functions that modify your Expo config and native projects. This guide shows you how to create your own plugins.

Plugin structure and exports

A config plugin is a function with this signature:
Plugin.types.ts

Basic plugin

The simplest plugin takes a config and returns it:

Plugin with props

Plugins can accept typed props:
Usage in app.json:

Naming conventions

Follow these naming conventions from the Expo ecosystem:

Function names

Start plugin functions with with:
This naming helps with:
  • Debugging: Stack traces show clear plugin names
  • Consistency: Matches Expo’s built-in plugins
  • Convention: Indicates the function is a config plugin

File names

For plugin files:
For packages shipping plugins:

Creating your first plugin

Let’s create a plugin that adds a custom URL scheme to your app.
1
Create the plugin file
Create plugins/withCustomScheme.ts:
plugins/withCustomScheme.ts
1
Use the plugin
Add it to your app.json:
app.json
1
Run prebuild
Your app now supports the myapp:// URL scheme on both platforms.

TypeScript types

Expo provides comprehensive TypeScript types for config plugins.

Core types

Plugin.types.ts

File type definitions

Helper to extract plugin parameter types

Plugin.types.ts
Usage:

Plugin helpers

createRunOncePlugin

Prevent a plugin from running multiple times:
withRunOnce.ts
This is useful for:
  • Preventing duplicate modifications
  • Migrating from unversioned to versioned plugins
  • Tracking plugin history

createInfoPlistPlugin

Helper for iOS Info.plist modifications:
ios-plugins.ts

createAndroidManifestPlugin

Helper for Android manifest modifications:
android-plugins.ts

createEntitlementsPlugin

Helper for iOS entitlements:
ios-plugins.ts

Composing multiple plugins

Plugins can chain other plugins:

Error handling

Use PluginError for better error messages:

Exporting plugins from packages

For npm packages, export your plugin from a plugin directory:
package.json:
plugin/src/index.ts:
Users install your package and add to app.json:
Expo automatically resolves to my-library/plugin.

Best practices

1. Keep plugins pure

Plugins should be deterministic:

2. Document your props

Use JSDoc comments:

3. Validate props early

4. Avoid side effects

Don’t write files or make network requests during plugin execution. Use mods instead:

5. Use helpers for common tasks

Leverage built-in helpers like createInfoPlistPlugin, createAndroidManifestPlugin, etc.

Next steps