Email app
This tutorial demonstrates how to build an app that allows a seller to send mass emails to their current members.
You could use it to:
- Send weekly updates on sports picks
- Send announcements to members
This app uses:
Prerequisites
Before we can start building, we need to create an app on Whop. If you haven’t already, head to the Developer Settings page and create a new app.
As this app is a Business-facing app, it will not be shown to the customer, so we will only need to set the seller path in our app settings.
- Seller Path:
/seller-view/$companyId
Project Setup
Resend Setup
To send emails, we will be using Resend. The app will need an API key to use the Resend SDK, so head to the Resend Dashboard and create a new API key.
Next.js Setup
Now that we have got our Resend API key, we can move on to the app itself. This tutorial will use Next.js with the App Directory
- Initialize a new project
- Install the dependencies
- Set up Environment Variables
To ensure that we don’t leave any sensitive information in our code, we are going to use environment variables to store our API keys.
Create a .env.local
file in the root of your project and add the following:
WHOP_API_KEY
is your Whop API key. You can find this in your app’s settings.NEXT_PUBLIC_WHOP_APP_ID
is your Whop App ID. You can find this in your app’s settings.RESEND_API_KEY
is the API key we created earlier.
Building the app
This section will walk you through building the app.
Structuring the project
Before we start building, we need to set up the project structure. We will:
- Create the path for our seller page
- Create a
lib
folder for our server-side logic - Create a
components
folder for our UI components - Setup Frosted UI
Creating the Seller page
Create a new path inside of the app
folder:
This will be the page that the seller sees when they open the app.
Creating the miscellaneous folders
To use Frosted UI, we need to edit our layout.tsx
and tailwind.config.ts
files.
Now, create a folder in the app directory called layout.client.tsx
. This is where we will define our client layout.
Finally, we need to edit the layout.tsx
file to use our new layout.
Finally, head to globals.css
and remove all the content except the 3 @tailwind
imports, like so:
Developing locally
To develop locally and see our changes on the Whop site, we need to use the whop-proxy
command. To do this, run the following command in your terminal:
To find out more about the whop-proxy
command, check out the
documentation.
Creating the Seller page
Now that we have our project setup, we can start building the app. We will start by creating the seller page.
In this file we will:
- Verify that the user is allowed to access the page
- Fetch all the products for the company
- Render the form to send emails
Creating the form
In this form, the seller will be able to select a specific product or all of them, and then input the email content, such as the subject and body.
Creating the server action
Now that we have created our form, we need to create the server action that will be triggered when the form is submitted. Create a new file called actions.ts
in the lib
folder.
In this file we will:
- Retrieve the email of each user for the selected product
- Send the emails using Resend
- Return a success/error message
Next Steps
If you have made it this far, congratulations! You have successfully built an app.
If you want to view the source code for this app, you can find it on GitHub