Best Practices
Packages and Dependencies
Because Cloudflare Workers do not utilize containerized processes running an instance of a language runtime, certain Nodejs-specific dependencies – such as fs or crypto – may not function correctly, or could prevent the project from publishing to the Cloudflare Worker correctly. But, any package that utilizes webpack or another polyfill bundler should run within the environment.
Deployment Tips
Add both your sandbox instance and your production instance when running npm run authenticate
. When you want to deploy your project to production, first deploy to your sandbox instance to preview the changes and then deploy to your production instance when you confirm the look and feel. If you didn’t add both instances when you ran npm run authenticate
you can simply go to you ti-config.json
file and enter the instance details there.
You should deploy early and often to your sandbox. Building a headless LMS and integrating with 3rd parties can introduce complexities if not done carefully.
3rd Party Libraries
Because Helium is fully open source and headless, you can easily use 3rd party developed libraries and components to quickly build a world class learning experience. However, there are some things to be careful about. Helium utilizes Cloudflare workers for hosting and not all components or libraries are compatible with the Helium stack. The quickest way to check is to install a 3rd party library and see if can still deploy successfully to your sandbox.
Writing GraphQL Queries
Only query the data you need, when you need it. One of the greatest features of GraphQL is that you only receive the data you need, nothing more and nothing less. Each component should only fetch data they need. While it is possible to run a single large query in the root component and then pass data to its child components, this can lead to poorer performance.
Querying CurrentUser
Due to limitations with Cloudflare Worker Request Header Size, CurrentUser
objects with larger allocatedLicenses
, allocatedLearningPaths
, purchasedCourses
, purchasedBundles
and other arrays, could have them truncated to a size that will pass the header limitation. Because of this, it is advised to query the CurrentUser
object for those specific properties when needed, to ensure you have all available, up-to-date data for the user as opposed to the CurrentUser
passed through PageProps
.
Still have a question?
Get your questions answered in our Developer Discord.