Migrating from SSE to SSE2

Key changes you'll need to make to utilize SSE2's new sse-core

Overview

SSE v2.0.0 (sse-core) introduces significant improvements that make working with Webflow sites easier and more maintainable. This guide will walk you through migrating your existing SSE v1.x code to v2.0.0.

Key Changes

  1. Package renamed: @sygnal/sse → @sygnal/sse-core

  2. New base classes: PageBase and ComponentBase with automatic context detection

  3. Lifecycle methods: setup()/exec() → onPrepare()/onLoad()

  4. Singleton pattern: Access page from components via PageBase.getCurrentPage()

  5. RouteDispatcher fix: Must create once and reuse the instance

Migration Steps

Step 1: Update Package

Update your package.json:

{
  "dependencies": {
    "@sygnal/sse-core": "^2.0.0"
  }
}

Then run:

Step 2: Update Import Statements

Find and replace all imports throughout your project:

Before:

After:

Step 3: Migrate Pages to PageBase

Before (v1.x):

After (v2.0):

Key Changes:

  • implements IModule → extends PageBase

  • Remove constructor (not needed)

  • setup() → protected onPrepare()

  • exec() → protected async onLoad()

  • Access this.pageInfo for all Webflow context (no manual DOM queries!)

Step 4: Migrate Components to ComponentBase

Before (v1.x):

After (v2.0):

Key Changes:

  • implements IModule → extends ComponentBase

  • Remove constructor (automatic element injection!)

  • setup() → protected onPrepare()

  • exec() → protected async onLoad()

  • this.elem → this.element (automatic)

  • Access this.context for component metadata

  • Access page via PageBase.getCurrentPage() singleton

Step 5: Fix RouteDispatcher Instance (CRITICAL)

This is a critical fix that prevents data loss between preparation and execution phases.

Before (v1.x - BROKEN):

After (v2.0 - CORRECT):

Update your src/index.ts:

Step 6: Update Route Registration (Optional)

If using automatic route discovery with getAllPages():

Step 7: Keep Site Class Using IModule

The Site class doesn't need automatic context, so it still uses IModule:

Available Automatic Context

PageBase - this.pageInfo Properties

When extending PageBase, you automatically get access to:

  • this.pageInfo.path - Current page path (e.g., "/blog/my-post")

  • this.pageInfo.url - Full URL

  • this.pageInfo.hash - URL hash fragment

  • this.pageInfo.queryParams - Parsed query parameters object

  • this.pageInfo.pageId - Webflow page ID

  • this.pageInfo.siteId - Webflow site ID

  • this.pageInfo.collectionId - CMS collection ID (if applicable)

  • this.pageInfo.itemId - CMS item ID (if applicable)

  • this.pageInfo.itemSlug - CMS item slug (if applicable)

  • this.pageInfo.domain - Webflow domain

  • this.pageInfo.lang - Page language

ComponentBase - this Properties

When extending ComponentBase, you automatically get:

  • this.element - The HTMLElement the component is bound to

  • this.context.name - Component name from data-component

  • this.context.id - Component ID from data-component-id

  • this.context.dataAttributes - All data-* attributes as key-value pairs

Benefits Summary

Feature
v1.x (IModule)
v2.0 (Base Classes)

Context Detection

Manual DOM queries

Automatic

Page Info

Parse attributes yourself

this.pageInfo.*

Component Element

Pass in constructor

this.element

Lifecycle Naming

setup()/exec()

onPrepare()/onLoad()

Page Access from Component

Pass references manually

PageBase.getCurrentPage()

Type Safety

Manual typing

Fully typed

Boilerplate Code

Lots

Minimal

Testing Your Migration

After migrating, verify:

  1. ✅ All pages load without console errors

  2. ✅ Page-specific code executes on correct routes

  3. ✅ Components initialize and function correctly

  4. ✅ this.pageInfo contains expected values in pages

  5. ✅ this.element and this.context work in components

  6. ✅ PageBase.getCurrentPage() returns page instance from components

  7. ✅ Data persists between onPrepare() and onLoad() phases

Common Issues

Issue: "Property 'pageInfo' does not exist"

Cause: Still using implements IModule instead of extends PageBase

Fix: Change class declaration:

Issue: Data lost between onPrepare() and onLoad()

Cause: Creating multiple RouteDispatcher instances

Fix: Store dispatcher in a variable and reuse:

Issue: "Cannot read property 'pageId' of undefined"

Cause: Trying to access pageInfo before context detection completes

Fix: PageInfo is available in both onPrepare() and onLoad(), but ensure you're extending PageBase correctly.

Backward Compatibility

The IModule interface is still fully supported for advanced use cases where you need manual control. You can mix and match:

  • Site class: Continue using IModule (recommended)

  • Pages: Use PageBase for automatic context (recommended)

  • Components: Use ComponentBase for automatic context (recommended)

  • Advanced cases: Use IModule when you need full manual control

Need Help?

If you encounter issues during migration:

  1. Check that all imports use @sygnal/sse-core

  2. Verify RouteDispatcher is created once and reused

  3. Ensure pages extend PageBase and components extend ComponentBase

  4. Check that lifecycle methods use new names (onPrepare/onLoad)

  5. Review the sse-template repository for complete examples

Last updated