libsFullCalendar component demonstrates how to integrate the FullCalendar library into a Lightning Web Component to create interactive calendars.
Source Code
- Component:
force-app/main/default/lwc/libsFullCalendar/ - Static Resource:
force-app/main/default/staticresources/fullCalendar/(containsmain.min.jsandmain.min.css)
Key Features
- Loads FullCalendar script and styles using
platformResourceLoader - Creates a month view calendar
- Uses manual DOM manipulation with
lwc:dom="manual" - Implements error handling with error panels
Loading FullCalendar Resources
The component loads both JavaScript and CSS files from the static resource:Initialization Pattern
The component uses therenderedCallback() lifecycle hook with a guard flag:
- Guard flag prevents multiple initializations
Promise.all()loads script and style in parallel- Errors are stored and displayed in the template
Calendar Initialization
The component initializes the calendar with Lightning Web Security check:- Checks for
FullCalendarglobal to ensure library loaded - Throws descriptive error if LWS is not enabled
- Creates calendar with day grid month view
- Renders calendar into the target element
Calendar Configuration
The example uses a basic configuration, but FullCalendar supports extensive options:Manual DOM Container
The template uses a container with manual DOM control:lwc:dom="manual" directive allows FullCalendar to directly manage the calendar DOM structure.
Error Handling
The component displays errors using the error panel pattern:Lightning Web Security Requirement
FullCalendar requires LWS because:- It uses modern JavaScript features
- Lightning Locker’s security restrictions prevent proper initialization
- The global
FullCalendarobject must be accessible
- Navigate to Setup > Session Settings
- Enable Use Lightning Web Security for Lightning web components
- Save your changes
Setting Up Static Resources
- Download FullCalendar from fullcalendar.io
- Create a ZIP file containing:
main.min.js(FullCalendar bundle)main.min.css(FullCalendar styles)
- Upload as a static resource named
fullCalendar - Reference it using
@salesforce/resourceUrl/fullCalendar
Adding Events
To add events to the calendar, extend the configuration:Related Components
- Chart.js Integration - Chart creation with Chart.js
- D3.js Integration - Data visualization with D3
