Getting Started
In this guide, you’ll create your first Data Client App to authorize with Webflow and make your first API request.
Prerequisites
To successfully follow along with this guide, please ensure you have the following:
- A Webflow site for development and testing
- A registered App on your Workspace. If you haven’t registered an App, follow along with our registration guide to create and register your first App with Webflow.
- The
sites:read
scope enabled on your App - Node.js installed on your machine.
Quick Start (5 minutes)
Add your credentials to .env
Navigate to your Workspace settings in the Webflow dashboard and find your Client ID and Secret in the Apps & Integrations -> App Development section. Replace the placeholder values in the .env.example
file with your own Client ID and Secret. Then save the file as .env
.
Create a tunnel to your local server
Create a tunnel to your local server using ngrok or localtunnel and update your Webflow App’s Redirect URL to point to your tunnel
Working with Ngrok
Authenticate Ngrok
Authenticate Ngrok with your auth token by typing the following code in your terminal
Start a tunnel to the port of your choosing
Start a tunnel to the port of your choosing by typing the following code in your terminal. This should be the same port you set in your .env
file.
Update App redirect URI
Copy the forwarding URI from the Ngrok session detail window.
- Navigate to your App’s details in the App Development section of your Workspace Settings.
- Click the “Edit App” button and navigate to the “Building Blocks” tab.
- In the Data Client section, update the redirect URI to the Ngrok forwarding URL with
/auth
added to the end. For example:https://939c-136-33-253-184.Ngrok.io/auth
Understanding the example
This example is a simple Node.js app that handles authorization and makes a single request to the Webflow API.
Let’s review the code in server.js
to understand how the App works.
Installation and configuration
The App uses Fastify to create a lightweight server, Level as a database to store data, and the Webflow JavaScript SDK to authenticate with Webflow and make requests to the API. To keep things simple, the frontend of the App is built with vanilla JavaScript and CSS, with a simple HTML file served from the public
directory.
In the beginning of server.js
, we’re importing the necessary dependencies, loading our environment variables, and initializing the Fastify server. Here, we’ve also added security headers to the server to protect against common web vulnerabilities, as well as initializing the database for storing access tokens.
OAuth Authentication
The App implements OAuth 2.0 authentication through a dedicated /auth
route that handles both initiating the authorization flow and processing Webflow’s callback response. When a user clicks “Connect with Webflow”, this route first redirects them to Webflow’s authorization page. After the user grants permission, Webflow redirects back to this route with an authorization code that the App exchanges for an access token.
For a comprehensive walkthrough of implementing OAuth 2.0 authentication in your App, refer to our detailed OAuth 2.0 guide.
Start the OAuth 2.0 authorization flow
This route will check for a code
query parameter. If the code is not present, we’ll redirect the user to the Webflow OAuth 2.0 authorization page using the authorizeURL
method of the Webflow JavaScript SDK.
Request an access token
If the code
query parameter is present, we’ll use it to request an access token from Webflow using the getAccessToken
method of the Webflow JavaScript SDK. We’ll also store the access token in the database and redirect the user to the root URL of the App.
The example App stores and retrieves a single access token directly in the Level database. In a production app, you’ll want to implement proper user management and token storage, including:
- Storing tokens securely per user/workspace
- Encrypting sensitive data
- Using secure session management
Consider using dedicated auth services or implementing these security measures using libraries like Passport.js, JWT tokens, and proper database encryption.
Making requests to the REST API
After the user has authorized the App, it can make requests to the REST API using the WebflowClient
object. Here, the /sites
route makes a request to the “List Sites” endpoint.
Before calling the API, the App retrieves the access token from the database and creates a new, authenticated WebflowClient
object.
Next Steps
Now that you have a working app, you can:
- Add More API Endpoints: Explore the API Reference and our Data Client Guides to add functionality
- Add Designer Extension capabilities: Learn how to add Designer Extension capabilities to your App.
- Authenticate a Hybrid App: Learn how to implement authentication for Apps using Data Client and Designer Extension capabilities.
- Prepare your Marketplace App: Learn how to prepare your App for submission to the Webflow Marketplace