This repo is a starter template to build, style, and deploy lightweight React apps to Salesforce Marketing Cloud CloudPages. It uses Vite for blazing-fast builds and Tailwind CSS for responsive styling. Built assets are deployed via SFMC Code Resources and embedded into CloudPages. This repo uses API hosted on code resource and written on SSJS.
This repository contains a lightweight, modern frontend boilerplate using Vite, React, and Tailwind CSS, built specifically for projects targeting Salesforce Marketing Cloud (SFMC) CloudPages.
It simplifies frontend development while making it easy to integrate compiled HTML, JS, and CSS assets into SFMC via CloudPages and Code Resources. It also helps in using modern frameworks to improve the capbility of the UI.
npm create vite@latest [project-name]
cd [project-name]
npm install -D tailwindcss@3 postcss autoprefixer
npx tailwindcss init -p
Update tailwind.config.js
:
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
Update src/index.css
:
@tailwind base;
@tailwind components;
@tailwind utilities;
Copy the below code in app.jsx
export default function App() {
return (
<h1 className="text-3xl font-bold underline">
Hello world!
</h1>
)
}
Run the below command to test locally.
npm run dev
npm run build
This generates the dist/
folder containing:
index.html
assets/index-[hash].js
assets/index-[hash].css
app-index.html
dist/index.html
in local code editor, copy its content, and paste it into the landing page.JavaScript
app.js
dist/assets/index-[hash].js
and paste itCSS
app.css
dist/assets/index-[hash].css
and paste it<script>
tag with:<script type="module" src="https://YOUR_JS_URL.js"></script>
<link>
tag with:<link rel="stylesheet" href="https://YOUR_CSS_URL.css" />
Javascript
CloudPagesURL
for PersonalizationWhen sending an email from SFMC, you can personalize a CloudPage by passing subscriber-specific data using the CloudPagesURL
function and query string parameters.
%%[
SET @link = CloudPagesURL(12345, "email", emailaddr, "name", FirstName)
]%%
<a href="%%=RedirectTo(@link)=%%">View Your Offer</a>
npm install
before running the code locally.
This repo was created and maintained by Yuvraj Singh Thakur.
Feel free to reach out for collaboration, feedback, or queries:
This project is intended for educational and internal use within Salesforce Marketing Cloud environments.
It is not officially affiliated with or endorsed by Salesforce.
Please test thoroughly before deploying to production.