What You Need to Know About Serverless Functions in HubSpot

HubSpot's Content Hub continues to evolve, offering powerful features across its Professional and Enterprise editions that make building and managing websites easier for both marketing teams and developers.

While the platform offers numerous benefits for marketers through features like themes and drag-and-drop editing, there are also significant capabilities for development teams, particularly in Content Hub Enterprise. One of the most powerful features that developers should be excited about is serverless functions.

Let's take a deeper look at how this capability can enhance your development workflow.

What Are Serverless Functions?

Serverless functions use resources provided by a cloud provider rather than resources on a dedicated server. This significantly expands what a developer can do within HubSpot because they no longer have to set up scripts on an external server. Instead of going through typical DevOps tasks, like purchasing a virtual personal server (VPS) and installing an operating system, developers can focus solely on writing code.

Additionally, serverless functions offer a way to write server-side code that interacts with HubSpot or another third-party service through the use of an API. APIs requiring authentication can potentially expose your credentials to end-users, but serverless functions act as an intermediary to keep those credentials safe. When your developers use serverless functions, they won't need to deal with the overhead associated with managing a server, which will give them more opportunities to build sophisticated functionality.

So, What Are Some Common Uses?

Serverless functions can be used for multiple purposes, but some ideas to quickly get up and running with them include:

  • HubSpot API Interactions
    • Updating a HubDB table based on form submissions or other actions
    • Manipulating contact properties without requiring form submissions
    • Retrieving specific details for contacts, deals, or other objects from the HubSpot API
    • Working with custom objects and their properties
  • Third-Party API Integration
    • Forwarding requests to non-HubSpot API services while keeping credentials secure
    • Server-side storage of secrets, preventing exposure to client browsers
    • Implementing controlled access to specific actions 
    • Examples include: event calendars, third-party service integrations, Google API integrations (Maps, Analytics, etc.), and social media interactions
  • Secure Business Logic
    • Protecting proprietary calculations or business logic
    • Example: Custom calculators where the logic needs to remain private
    • Processing sensitive data away from client-side exposure
  • Membership and Authentication
    • Integration with Content Hub membership features
    • User authentication and authorization
    • Creating secure member portals with personalized data access
    • Controlling access to specific deals or content based on user permissions

Other Important Considerations Regarding Serverless Functions

Serverless functions help reduce the number of systems your company depends on. If you have a website on HubSpot and some vital script on some third-party platform, you’re relying on both of those to not go down. If your script is a serverless function instead, you only depend on HubSpot.

In a similar vein, serverless functions make your developers’ lives easier by keeping a complex project all within the HubSpot ecosystems. Your developers don’t have to go to a separate platform to manage server-side stuff, and it’s easier to edit client-side and server-side scripts in the same place. But before your development team goes running off to use serverless functions, there are a few limitations to be aware of, as noted from HubSpot: 

  • 50 secrets per account
  • 128MB of memory
  • 10 seconds of execution time
  • 60 function executions per minute
  • 600 seconds (10 minutes) of function execution time per minute (This means you can run either 60 functions that take 10 seconds each OR 600 functions that take 1 second each in a single minute)
  • Maximum of 100 endpoints per HubSpot account

Get Started

Serverless functions remains a powerful feature, opening up numerous possibilities for your development team. They enable sophisticated integrations and secure processing while maintaining the simplicity and reliability of the HubSpot platform.

For more information about Content Hub and its features, keep an eye on our blog. If you want to discuss implementing serverless functions for your specific use case, reach out today!

By: Corie Stark

After spending many years as a sports journalist, Corie switched to marketing in 2013. Her love of writing, talking to people, and keeping up with the industry enables her to use her skills for anything from social media to long-form blogging. Outside of work, she enjoys hiking with her dogs and making her cats chase the ever elusive red dot.

Subscribe Today

Stay Up-to-Date With HubSpot and Marketing Trends

Never miss a beat with the latest marketing strategies and tactics. Subscribe to the Lynton blog and receive valuable insights straight to your inbox.