|
| 1 | +# Funnel Builder Extension |
| 2 | + |
| 3 | +The Funnel Builder extension adds multi-step funnel capabilities to Webiny's Website Builder. |
| 4 | + |
| 5 | +> **Architecture Change from v5**: Unlike Webiny v5 where everything was on the Webiny side, v6 separates concerns: **public website rendering happens in Next.js**, while **Webiny Admin is purely an editor UI** for building funnels, managing steps, defining condition rules, and dropping fields. All visual components and React code live in your Next.js app. See [How It All Fits Together](https://www.webiny.com/learn/course/website-builder/setting-up-website-builder) for details. |
| 6 | +
|
| 7 | +> **Note**: This README covers the Webiny backend extension setup. For Next.js frontend implementation details (multi-tenancy, theming, component customization), see the [Next.js Starter Kit README](https://github.com/webiny/website-builder-nextjs/blob/funnel-builder/README.md). |
| 8 | +
|
| 9 | +## Setup Guide |
| 10 | + |
| 11 | +### Step 1: Install the Extension |
| 12 | + |
| 13 | +This extension is already installed in your Webiny project. If you need to verify, check that `extensions/funnelBuilder/` exists in your project root. |
| 14 | + |
| 15 | +### Step 2: Clone the Next.js Starter Kit |
| 16 | + |
| 17 | +The Funnel Builder requires a Next.js frontend app to render your funnels. Clone the official starter kit with funnel support: |
| 18 | + |
| 19 | +```bash |
| 20 | +git clone -b funnel-builder https://github.com/webiny/website-builder-nextjs.git my-funnel-app |
| 21 | +cd my-funnel-app |
| 22 | +npm install |
| 23 | +``` |
| 24 | + |
| 25 | +**Important**: Make sure to clone the `funnel-builder` branch, which includes all the necessary funnel components. |
| 26 | + |
| 27 | +**Note**: Once cloned, you can move this code to your own private repository for version control and customization. The starter kit is meant to be a starting point for your own project. |
| 28 | + |
| 29 | +Before running `npm install`, verify that the `@webiny/website-builder-nextjs` and `@webiny/sdk` versions in `package.json` match your Webiny version. You can check your version with: |
| 30 | + |
| 31 | +```bash |
| 32 | +webiny --version |
| 33 | +``` |
| 34 | + |
| 35 | +If your Webiny version is `6.2.1`, your `package.json` should have: |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "dependencies": { |
| 40 | + "@webiny/website-builder-nextjs": "~6.2.1", |
| 41 | + "@webiny/sdk": "~6.2.1" |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +### Step 3: Start Your Webiny Admin App |
| 47 | + |
| 48 | +You'll need the Admin app running to configure the Next.js connection: |
| 49 | + |
| 50 | +- **Locally**: Run `yarn webiny watch admin` in your Webiny project directory |
| 51 | +- **Deployed**: Use your Admin CloudFront URL directly |
| 52 | + |
| 53 | +### Step 4: Get Your API Credentials |
| 54 | + |
| 55 | +In Webiny Admin: |
| 56 | + |
| 57 | +1. Click **Support** in the bottom-left sidebar |
| 58 | +2. Select **Configure Next.js** |
| 59 | +3. Copy the environment variables shown in the dialog |
| 60 | + |
| 61 | +The dialog will show: |
| 62 | + |
| 63 | +```bash |
| 64 | +NEXT_PUBLIC_WEBSITE_BUILDER_API_KEY=your-api-key-here |
| 65 | +NEXT_PUBLIC_WEBSITE_BUILDER_API_HOST=https://your-api-host.com |
| 66 | +NEXT_PUBLIC_WEBSITE_BUILDER_API_TENANT=root |
| 67 | +``` |
| 68 | + |
| 69 | +**Note**: The `NEXT_PUBLIC_WEBSITE_BUILDER_API_TENANT` variable is only needed when working with a single tenant. The Next.js starter kit resolves tenant at runtime from the hostname subdomain (for public traffic) or the `wb.tenant` query param (from the editor iframe). See the Next.js repo README for details on multi-tenant setup. |
| 70 | + |
| 71 | +If your Admin is running on a non-localhost domain (deployed CloudFront URL), the dialog will also include `NEXT_PUBLIC_WEBSITE_BUILDER_ADMIN_HOST` — make sure to copy that too. |
| 72 | + |
| 73 | +### Step 5: Configure Your Next.js App |
| 74 | + |
| 75 | +Create a `.env` file in your Next.js project root: |
| 76 | + |
| 77 | +```bash |
| 78 | +NEXT_PUBLIC_WEBSITE_BUILDER_API_KEY=your-api-key-here |
| 79 | +NEXT_PUBLIC_WEBSITE_BUILDER_API_HOST=https://your-api-host.com |
| 80 | +# NEXT_PUBLIC_WEBSITE_BUILDER_API_TENANT=root # Only needed for single-tenant setups |
| 81 | +``` |
| 82 | + |
| 83 | +### Step 6: Start the Next.js Dev Server |
| 84 | + |
| 85 | +```bash |
| 86 | +npm run dev |
| 87 | +``` |
| 88 | + |
| 89 | +Your Next.js app will be available at [http://localhost:3000](http://localhost:3000). |
| 90 | + |
| 91 | +## Creating Your First Funnel |
| 92 | + |
| 93 | +1. In Webiny Admin, go to **Website Builder → Pages** |
| 94 | +2. Click **New Page** |
| 95 | +3. Set the **Page Type** to **Funnel** |
| 96 | +4. Set a **Title** (e.g., "Lead Generation Funnel") and **Path** (e.g., `/get-started`) |
| 97 | +5. Click **Create** |
| 98 | +6. Build your funnel using the available components in the editor |
| 99 | +7. Click **Publish** |
| 100 | +8. Visit your Next.js app at the configured path (e.g., `http://localhost:3000/get-started`) |
| 101 | + |
| 102 | +The funnel editor and components work the same as in Webiny v5. If you're migrating from v5, you'll find all the familiar mechanics and features. |
| 103 | + |
| 104 | +## Tenant Theming |
| 105 | + |
| 106 | +The Funnel Builder extension extends the Webiny Tenant model with theme settings that can be accessed by your Next.js app for dynamic styling. |
| 107 | + |
| 108 | +### Theme Fields Added to Tenant Settings |
| 109 | + |
| 110 | +The extension adds a "Theme" section to **Tenant Settings** with the following fields: |
| 111 | + |
| 112 | +- **Primary Color**: Primary brand color (e.g., `#ff0000`) |
| 113 | +- **Secondary Color**: Secondary brand color (e.g., `#0000ff`) |
| 114 | +- **Logo URL**: URL of the tenant logo |
| 115 | + |
| 116 | +These values are stored under `tenant.extensions.theme` and can be fetched via the Webiny SDK. |
| 117 | + |
| 118 | +### Accessing Theme Values in Next.js |
| 119 | + |
| 120 | +Your Next.js app can fetch these tenant-specific theme values using the SDK: |
| 121 | + |
| 122 | +```typescript |
| 123 | +import { createSdk } from "@/src/lib/webiny"; |
| 124 | + |
| 125 | +const result = await createSdk(tenantId).tenantManager.getCurrentTenant(); |
| 126 | +const theme = result.value.values.extensions?.theme ?? {}; |
| 127 | + |
| 128 | +// theme.primaryColor |
| 129 | +// theme.secondaryColor |
| 130 | +// theme.logo |
| 131 | +``` |
| 132 | + |
| 133 | +The Next.js starter kit includes `getTenantThemeCss()` which automatically fetches these values and generates CSS custom properties that can be used throughout your app. See the Next.js repo README for implementation details. |
| 134 | + |
| 135 | +### Configuring Theme Values |
| 136 | + |
| 137 | +**For Non-Root Tenants:** |
| 138 | + |
| 139 | +1. In Webiny Admin, go to **Settings → Tenant Settings** |
| 140 | +2. Find the **Theme** section |
| 141 | +3. Set your Primary Color, Secondary Color, and Logo URL |
| 142 | +4. Save the settings |
| 143 | +5. Your Next.js app will automatically fetch and apply these values on the next request |
| 144 | + |
| 145 | +**For Root Tenant:** |
| 146 | + |
| 147 | +The Theme settings UI is not available for the root tenant. If you need to configure theme values for the root tenant, you must edit them via the API using the Tenant Manager SDK. |
| 148 | + |
| 149 | +```typescript |
| 150 | +// Example: Update root tenant theme via API |
| 151 | +const sdk = createSdk("root"); |
| 152 | +await sdk.tenantManager.updateTenant({ |
| 153 | + id: "root", |
| 154 | + values: { |
| 155 | + extensions: { |
| 156 | + theme: { |
| 157 | + primaryColor: "#ff0000", |
| 158 | + secondaryColor: "#0000ff", |
| 159 | + logo: "https://example.com/logo.png" |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | +}); |
| 164 | +``` |
| 165 | + |
| 166 | +## Learn More |
| 167 | + |
| 168 | +- **Website Builder Docs**: [webiny.com/learn/course/website-builder](https://www.webiny.com/learn/course/website-builder/setting-up-website-builder) |
| 169 | +- **Next.js Starter Kit**: [github.com/webiny/website-builder-nextjs](https://github.com/webiny/website-builder-nextjs) (funnel-builder branch) |
| 170 | +- **Webiny Community**: [webiny.com/slack](https://www.webiny.com/slack) |
0 commit comments