This guide will demonstrate how to add custom code to a pre-configured example site. You will learn how to register scripts to a site, apply them to a page, and publish the site, illustrating the complete process of managing scripts via the API.
A clone of the Code Example Site.
A Webflow App with the following scopes: sites:read, sites:write, pages:read, pages:write, custom_code:read, and custom_code:write.
Only Webflow Apps with OAuth tokens can call the custom code API endpoints, not clients with site or Workspace tokens.
An Ngrok account and authentication token. This guide uses Ngrok to set up a secure tunnel for the App.

Clone the Project Repository Run the following commands in your IDE to clone the example repository and install dependencies:
Configure Environment Variables
Fill out a .env file with the necessary environment variables:
Start the Project Run the following command in your IDE to start the project:
Update App’s Redirect URI Once the server is running, copy the Redirect URI provided in the terminal. Navigate to your Webflow Workspace dashboard, go to “Apps & Integrations,” and update the Redirect URI in your App settings. Save the changes.

Authorize App
We’ll need to authorize the App to access the newly cloned example site. We’ve already set up the authorization flow in this example App. Navigate to localhost:8080 and choose the workspaces or sites you want your App to access. Once authorized, you’ll be redirected to the App’s frontend.
To see how we configured authorization for this App, navigate to the backend folder and review controllers/authController.js, routes/authRoutes.js, and webflowClientMiddleware.js. For more information on setting up authorization, read through our authorization guide.
In this step, you will register scripts necessary for implementing custom functionality on your Webflow site. The App provides three example scripts that correspond to functionalities you can implement on the example site. We’ll start with Pointer Tracking, a script that enables an animation to follow your pointer around on the screen. We’d like to give Jeff McAvoy at RiveFlow a special thanks for contributing this example to the Webflow developer community.
Choose the Pointer Tracking Example
From the list of example scripts, select “Pointer Tracking.” Once selected, you’ll see a list of scripts to register that are marked inline or hosted.
Hosted scripts require a hostedLocation (the URL where the script is hosted) and an integrityHash to verify the script’s contents.
The following controller logic in the example app automates this process:
hostedLocationintegrityHash to ensure the script hasn’t been tampered withThis verification step ensures the script’s integrity before it’s applied to your Webflow site.
Provide script details
To upload a script via the API, you’ll need to provide the following details:
displayName (string): The name of your scriptversion (string): The semantic version of your script. Each script must have a unique combination of displayName and version. You cannot overwrite scripts at this time.canCopy (Boolean): Define whether the script can be copied on site duplication and transferFor the example we’ve already included the hostedLocation if it’s a hosted script, or the sourceCode if it’s an inline script.
Click register
Depending on the type of script, inline or hosted, this button will send your script to the backend server, and then to the appropriate Webflow endpoint.
Once you’re finished registering your scripts, click the “Next” button.
Now that a script has been registered to the Webflow site, you can use the API to apply scripts to either the entire site or a specific page. In this step, you will apply each script to the appropriate page for the chosen example.
Scripts can be applied to one of two locations:
<head> tag.</body> tag.Select a Page Choose the page where you’ll apply the script. For this example, we’ll select the “Pointer Tracking” page.
View Registered Scripts You will see a list of scripts that have been registered to your site, populated by the Get Scripts endpoint.
hostedLocation.hostedLocation URLs, as Webflow uploads these scripts to its CDN for serving.Apply Scripts
To apply the scripts we’ve registered to the page, we’ll use the Add/Update Custom Code endpoint. This endpoint requires you to add all custom code blocks to the page. Therefore, we’ll also use the Get Custom Code endpoint to retrieve any existing applied scripts, also known as custom code blocks, and upload a complete list of code that should be on the site.
We’ve applied this logic in our example app in backend/controllers/scriptControllers.js
Bonus: Check the Page in the Designer
The Webflow Designer allows users to see how apps integrate code into their sites. After applying a script to a site or page, you can view it in the Designer’s settings.
Before you can see your scripts in action, you’ll need to publish your entire site. Click the “Publish Site” button to publish your site using the Publish Site endpoint.
Once your site is published, click “View Page” to go directly to your Pointer Tracking page. You should now see a fun animation that follows your pointer around the page.

Awesome! Now that you’ve got the hang of custom code, here are some other cool things you can do:
Keep experimenting and enhancing your Webflow site with custom scripts!