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
Package renamed:
@sygnal/sse→@sygnal/sse-coreNew base classes:
PageBaseandComponentBasewith automatic context detectionLifecycle methods:
setup()/exec()→onPrepare()/onLoad()Singleton pattern: Access page from components via
PageBase.getCurrentPage()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 PageBaseRemove constructor (not needed)
setup()→protected onPrepare()exec()→protected async onLoad()Access
this.pageInfofor all Webflow context (no manual DOM queries!)
Step 4: Migrate Components to ComponentBase
Before (v1.x):
After (v2.0):
Key Changes:
implements IModule→extends ComponentBaseRemove constructor (automatic element injection!)
setup()→protected onPrepare()exec()→protected async onLoad()this.elem→this.element(automatic)Access
this.contextfor component metadataAccess 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 URLthis.pageInfo.hash- URL hash fragmentthis.pageInfo.queryParams- Parsed query parameters objectthis.pageInfo.pageId- Webflow page IDthis.pageInfo.siteId- Webflow site IDthis.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 domainthis.pageInfo.lang- Page language
ComponentBase - this Properties
When extending ComponentBase, you automatically get:
this.element- The HTMLElement the component is bound tothis.context.name- Component name fromdata-componentthis.context.id- Component ID fromdata-component-idthis.context.dataAttributes- All data-* attributes as key-value pairs
Benefits Summary
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:
✅ All pages load without console errors
✅ Page-specific code executes on correct routes
✅ Components initialize and function correctly
✅
this.pageInfocontains expected values in pages✅
this.elementandthis.contextwork in components✅
PageBase.getCurrentPage()returns page instance from components✅ Data persists between
onPrepare()andonLoad()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
PageBasefor automatic context (recommended)Components: Use
ComponentBasefor automatic context (recommended)Advanced cases: Use
IModulewhen you need full manual control
Need Help?
If you encounter issues during migration:
Check that all imports use
@sygnal/sse-coreVerify RouteDispatcher is created once and reused
Ensure pages extend
PageBaseand components extendComponentBaseCheck that lifecycle methods use new names (
onPrepare/onLoad)Review the sse-template repository for complete examples
Last updated