This guide will help you get up and running with the Framer Server API.
In order to interact with the Server API, you will need an API key. These keys authenticate your script as the user who created them, and are bound to a specific project.
You can generate a new API key by going to the General section in Site Settings for a project.
Save the key for future use; keep it in a secure location, such as an .env file or your password manager.
You can install the Server API node package with npm:
Create a JavaScript or TypeScript file:
import { connect } from "framer-api"
const framer = await connect(
"https://framer.com/projects/<id>",
process.env.FRAMER_API_KEY
)
const projectInfo = await framer.getProjectInfo()
console.log(`Project: ${projectInfo.name}`)
await framer.disconnect()import { connect } from "framer-api"
const framer = await connect(
"https://framer.com/projects/<id>",
process.env.FRAMER_API_KEY
)
const projectInfo = await framer.getProjectInfo()
console.log(`Project: ${projectInfo.name}`)
await framer.disconnect()import { connect } from "framer-api"
const framer = await connect(
"https://framer.com/projects/<id>",
process.env.FRAMER_API_KEY
)
const projectInfo = await framer.getProjectInfo()
console.log(`Project: ${projectInfo.name}`)
await framer.disconnect()Note that if your runtime supports it (e.g. TypeScript 5.2+), you can use the new using syntax to avoid needing to call framer.disconnect. In which case it would simply be:
using framer = await connect(
"https://framer.com/projects/<id>",
process.env.FRAMER_API_KEY
)
using framer = await connect(
"https://framer.com/projects/<id>",
process.env.FRAMER_API_KEY
)
using framer = await connect(
"https://framer.com/projects/<id>",
process.env.FRAMER_API_KEY
)
With your credentials (you can also put them in a .env file):
FRAMER_API_KEY="..." node script.js
FRAMER_API_KEY="..." node script.js
FRAMER_API_KEY="..." node script.js
Here is a quick example of how to connect, publish a new preview, and promote it to production.
import { connect } from "framer-api"
const framer = await connect(projectUrl, process.env.FRAMER_API_KEY)
const changes = await framer.getChangedPaths()
console.log(changes)
const result = await framer.publish()
console.log(result)
await framer.deploy(result.deployment.id)import { connect } from "framer-api"
const framer = await connect(projectUrl, process.env.FRAMER_API_KEY)
const changes = await framer.getChangedPaths()
console.log(changes)
const result = await framer.publish()
console.log(result)
await framer.deploy(result.deployment.id)import { connect } from "framer-api"
const framer = await connect(projectUrl, process.env.FRAMER_API_KEY)
const changes = await framer.getChangedPaths()
console.log(changes)
const result = await framer.publish()
console.log(result)
await framer.deploy(result.deployment.id)You can find a list of other real-world examples on the following GitHub repository: https://github.com/framer/server-api-examples.