Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
7d55b1a
fixed code snippets and added ts config
stb13579 May 3, 2022
cf6423f
added new introduction
stb13579 May 4, 2022
e9f7a09
revised wording
stb13579 May 6, 2022
2da98dc
add tabs card
stb13579 Jun 1, 2022
5665e09
Add code snippets for providers
stb13579 Jun 2, 2022
b036b88
Reorg doc structure
stb13579 Jun 2, 2022
18a3f35
adds Using Providers page
gpene Jun 20, 2022
e9b12f3
fix tabs
gpene Jun 21, 2022
c52be49
rework text
stb13579 Jun 21, 2022
d2fac4d
start programmatic use section
stb13579 Jun 21, 2022
7718325
Rework the email template section
stb13579 Jun 21, 2022
b1f2581
various changes
stb13579 Jun 21, 2022
2311f36
Add code example for lifecycle hook in admin panel
stb13579 Jun 21, 2022
03b4b6b
add temp links to new providers page
stb13579 Jun 22, 2022
1256056
delete configure the plugin
stb13579 Jun 22, 2022
2a58a11
change wording about SendMail
stb13579 Jun 22, 2022
0833470
finalize intro topics
stb13579 Jun 22, 2022
b282c4b
remove unused content
stb13579 Jun 22, 2022
0165e22
Cleanup code examples and remove troubleshooting section
stb13579 Jun 22, 2022
4105d5b
comment out last section for now
stb13579 Jun 22, 2022
64ff396
fix grammar
stb13579 Jun 22, 2022
c0687d6
add html tags to table
stb13579 Jun 22, 2022
3f488f1
small content edit
stb13579 Jun 22, 2022
a645e6e
Adding Sentry plugin doc
gpene Jun 23, 2022
6f4507e
fix tables
gpene Jun 23, 2022
390bb41
fix controller code example
stb13579 Jun 24, 2022
44c19e0
updated some language
stb13579 Jun 27, 2022
f1b64b7
update lifecycle hook section
stb13579 Jun 27, 2022
5df7c3b
improve spelling an grammar
stb13579 Jun 27, 2022
19a6547
improve misc things
stb13579 Jun 27, 2022
5b96974
improve the introduction
stb13579 Jun 27, 2022
49007b0
update table and misc improvements
stb13579 Jun 27, 2022
7f1391a
improved lifecycle hook text
stb13579 Jun 27, 2022
c6f7dd1
Fix email plugin caps
stb13579 Jun 29, 2022
d91c124
fix
stb13579 Jun 29, 2022
5f98871
Add missing closing </ul> that prevented VuePress rendering
pwizla Jun 29, 2022
50c65c5
add bullet points
stb13579 Jun 29, 2022
a73a9a7
remove unnecessary fragment
stb13579 Jun 30, 2022
9e3f414
rework intro
stb13579 Jun 30, 2022
8cf2a2e
Update based on feedback
gpene Jun 30, 2022
d37dd64
Update upload.md
gpene Jun 27, 2022
15c27c9
improved various parts
stb13579 Jul 4, 2022
772881a
add call out and fix titles
stb13579 Jul 4, 2022
09fc109
misc improvements
stb13579 Jul 4, 2022
c342e58
simplify wording
stb13579 Jul 4, 2022
53e2890
fix code block file paths and header levels
stb13579 Jul 4, 2022
22c4c5d
fixed various parts
stb13579 Jul 5, 2022
bc5825f
update node engines
stb13579 Jul 5, 2022
1f43dbe
add spaces to empty object braces
stb13579 Jul 5, 2022
6bb3eb5
trim content
stb13579 Jul 5, 2022
edd8bfd
shorten send func disc
stb13579 Jul 5, 2022
1f342f8
feedback updates
gpene Jul 7, 2022
fec3cb3
add optional to table
stb13579 Jul 7, 2022
b92ee45
Add send function properties table
stb13579 Jul 7, 2022
872d4b8
updated send function table
stb13579 Jul 7, 2022
3230752
add spacing
stb13579 Jul 8, 2022
40da374
Update docs/developer-docs/latest/plugins/email.md
stb13579 Jul 8, 2022
722c299
updated minor wording + delint
stb13579 Jul 8, 2022
db93e9b
add space
stb13579 Jul 8, 2022
a4f37f8
feedback revisions
gpene Jul 11, 2022
c6fb0af
modify `send` properties table
stb13579 Jul 11, 2022
99a7fba
feedback
gpene Jul 11, 2022
b47cbe3
feedback
gpene Jul 11, 2022
f1e3658
revisions
gpene Jul 11, 2022
8f2c7b5
fix links in admin panel config file
stb13579 Jul 11, 2022
9a05da4
delint
stb13579 Jul 11, 2022
fd5f55f
Merge branch 'dev/sentry-plugin' into dev/plugins-providers-master
gpene Jul 12, 2022
3facd92
Merge branch 'dev/upload-plugin' into dev/plugins-providers-master
gpene Jul 12, 2022
de7f01f
Merge branch 'dev/using-providers' into dev/plugins-providers-master
gpene Jul 12, 2022
b1005ad
Merge branch 'dev/email-plugin' into dev/plugins-providers-master
gpene Jul 12, 2022
4767b19
minor fixes
gpene Jul 12, 2022
80aae64
Update docs/developer-docs/latest/development/using-providers.md
gpene Jul 12, 2022
f09fdfd
Update docs/developer-docs/latest/plugins/email.md
stb13579 Jul 12, 2022
551137c
Update docs/developer-docs/latest/plugins/email.md
stb13579 Jul 12, 2022
c820b22
Feedback
gpene Jul 12, 2022
2661e61
Merge branch 'dev/plugins-providers-master' of https://github.com/str…
gpene Jul 12, 2022
5cd4701
title fix
gpene Jul 12, 2022
af525a5
add table
gpene Jul 12, 2022
090f4bc
Add Sentry to PluginLinks component
gpene Jul 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/.vuepress/config/sidebar-developer.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const developer = [
['/developer-docs/latest/development/admin-customization', 'Admin panel customization'],
['/developer-docs/latest/development/plugins-extension.md', 'Plugins extension'],
['/developer-docs/latest/development/plugins-development.md', 'Plugins development'],
['/developer-docs/latest/development/providers.md', 'Providers'],
],
},
{
Expand Down Expand Up @@ -423,6 +424,7 @@ const developer = [
['/developer-docs/latest/plugins/users-permissions', 'Users & Permissions'],
['/developer-docs/latest/plugins/email', 'Email'],
['/developer-docs/latest/plugins/upload', 'Upload'],
['/developer-docs/latest/plugins/sentry', 'Sentry'],
['/developer-docs/latest/plugins/documentation', 'API Documentation'],
],
sidebarDepth: 1,
Expand Down
13 changes: 13 additions & 0 deletions docs/.vuepress/theme/global-components/PluginsLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@
</template>
</InstallLink>
</div>

<!-- Sentry -->
<div>
<InstallLink link="/developer-docs/latest/plugins/sentry.html">
<template #icon>
<svg class="css-lfbo6j e10nushx4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 72 66" width="30" height="28"><path d="M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z" transform="translate(11, 11)" fill="#362d59"></path></svg>
</template>
<template #title>Sentry</template>
<template #description>
Plugin to track errors in your Strapi application using Sentry
</template>
</InstallLink>
</div>
</div>
</template>

Expand Down
203 changes: 203 additions & 0 deletions docs/developer-docs/latest/development/providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
---
title: Providers - Strapi Developer Docs
description: Install and use providers to extend the functionality of available plugins.
canonicalUrl: https://docs.strapi.io/developer-docs/latest/development/providers.html
---

# Providers

Certain [plugins](../../../user-docs/latest/plugins/introduction-to-plugins.md) can be extended via the installation and configuration of additional [providers](../../../user-docs/latest/plugins/introduction-to-plugins.md#providers).

Providers add an extension to the core capabilities of the plugin, for example to upload media files to Rackspace instead of the local server, or using Amazon SES for emails instead of Sendmail.

::: note
Only the [Upload](../plugins/upload.md) and [Email](../plugins/email.md) plugins are currently designed to work with providers.
:::

For the relevant plugins, there are both official providers maintained by Strapi - discoverable via the [Marketplace](../../../user-docs/latest/plugins/installing-plugins-via-marketplace.md) - and many community maintained providers available via [npm](https://www.npmjs.com/).

## Installing providers

New providers can be installed using `npm` or `yarn` using the following format `@strapi/provider-<plugin>-<provider> --save`.

For example:

<code-group>

<code-block title="NPM">
```sh
# Install the AWS S3 provider for the Upload plugin
npm install @strapi/provider-upload-aws-s3 --save

# Install the Sendgrid provider for the Email plugin
npm install @strapi/provider-email-sendgrid --save
```
</code-block>

<code-block title="YARN">
```sh
# Install the AWS S3 provider for the Upload plugin
yarn add @strapi/provider-upload-aws-s3

# Install the Sendgrid provider for the Email plugin
yarn add @strapi/provider-email-sendgrid --save
```
</code-block>

</code-group>

## Configuring providers

Newly installed providers are enabled and configured in the `./config/plugins.js` file. If this file does not exist you must create it.

Each provider will have different configuration settings available. Review the respective entry for that provider in the [Marketplace](../../../user-docs/latest/plugins/installing-plugins-via-marketplace.md) or [npm](https://www.npmjs.com/) to learn more.

Below are example configurations for the Upload and Email plugins.

:::: tabs card

::: tab Upload

```js
// path: ./config/plugins.js

module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: 'aws-s3', // For community providers pass the full package name (e.g. provider: 'strapi-provider-upload-google-cloud-storage')
providerOptions: {
accessKeyId: env('AWS_ACCESS_KEY_ID'),
secretAccessKey: env('AWS_ACCESS_SECRET'),
region: env('AWS_REGION'),
params: {
Bucket: env('AWS_BUCKET'),
},
},
},
},
// ...
});
```

::: note
Strapi has a default [`security` middleware](/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.md#security) that has a very strict `contentSecurityPolicy` that limits loading images and media to `"'self'"` only, see the example configuration on the [provider page](https://www.npmjs.com/package/@strapi/provider-upload-aws-s3) or the [middleware documentation](/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.md#security) for more information.
:::

::: tab Email

```js
module.exports = ({ env }) => ({
// ...
email: {
config: {
provider: 'sendgrid', // For community providers pass the full package name (e.g. provider: 'strapi-provider-email-mandrill')
providerOptions: {
apiKey: env('SENDGRID_API_KEY'),
},
settings: {
defaultFrom: 'juliasedefdjian@strapi.io',
defaultReplyTo: 'juliasedefdjian@strapi.io',
testAddress: 'juliasedefdjian@strapi.io',
},
},
},
// ...
});
```

Keep in mind that:

* When using a different provider per environment, specify the correct configuration in `./config/env/${yourEnvironment}/plugins.js` (See [Environments](/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md)).
* Only one email provider will be active at a time. If the email provider setting isn't picked up by Strapi, verify the `plugins.js` file is in the correct folder.
* When testing the new email provider with those two email templates created during strapi setup, the _shipper email_ on the template defaults to `no-reply@strapi.io` and needs to be updated according to your email provider, otherwise it will fail the test (See [Configure templates locally](/user-docs/latest/settings/configuring-users-permissions-plugin-settings.md#configuring-email-templates)).

:::

::::

### Configuration per environment

When configuring your provider you might want to change the configuration based on the `NODE_ENV` environment variable or use environment specific credentials.

You can set a specific configuration in the `./config/env/{env}/plugins.js` configuration file and it will be used to overwrite the default configuration.

## Creating providers

To implement your own custom provider you must [create a Node.js module](https://docs.npmjs.com/creating-node-js-modules).

The interface that must be exported depends on the plugin you are developing the provider for. Below are templates for the Upload and Email plugins:

:::: tabs card

::: tab Upload

```js
module.exports = {
init(providerOptions) {
// init your provider if necessary

return {
upload(file) {
// upload the file in the provider
// file content is accessible by `file.buffer`
},
uploadStream(file) {
// upload the file in the provider
// file content is accessible by `file.stream`
},
delete(file) {
// delete the file in the provider
},
};
},
};
```
:::
::: tab Email

```js
module.exports = {
init: (providerOptions = {}, settings = {}) => {
return {
send: async options => {},
};
},
};
```

In the send function you will have access to:

* `providerOptions` that contains configurations written in `plugins.js`
* `settings` that contains configurations written in `plugins.js`
* `options` that contains options you send when you call the send function from the email plugin service

:::

::::

You can review the [Strapi maintained providers](https://github.com/strapi/strapi/tree/master/packages/providers) for example implementations.

After creating your new provider you can [publish it to npm](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages) to share with the community or [use it locally](#local-providers) for your project only.

### Local providers

If you want to create your own provider without publishing it on npm you can follow these steps:

1. Create a `providers` folder in your application.
2. Create your provider (e.g. `./providers/strapi-provider-<plugin>-<provider>`)
3. Then update your `package.json` to link your `strapi-provider-<plugin>-<provider>` dependency to the [local path](https://docs.npmjs.com/files/package.json#local-paths) of your new provider.

```json
{
...
"dependencies": {
...
"strapi-provider-<plugin>-<provider>": "file:providers/strapi-provider-<plugin>-<provider>",
...
}
}
```

4. Update your `./config/plugins.js` file to [configure the provider](#configuring-providers).
5. Finally, run `yarn install` or `npm install` to install your new custom provider.
Loading