Puter.js - A JavaScript library for interacting with Puter services.
npm install @heyputer/puter.jsThe official JavaScript SDK for Puter.com
Free, Serverless, Cloud and AI from the frontend code.
Learn More
·
Docs
·
Tutorials
·
Examples
·
X
sh
npm install @heyputer/puter.js
`$3
Include Puter.js directly in your HTML via CDN in the
section:`html
`
Usage
$3
#### ES Modules
`js
import {puter} from '@heyputer/puter.js';
// or
import puter from '@heyputer/puter.js';
// or
import '@heyputer/puter.js'; // puter will be available globally
`#### CommonJS
`js
const {puter} = require('@heyputer/puter.js');
// or
const puter = require('@heyputer/puter.js');
// or
require('@heyputer/puter.js'); // puter will be available globally
`#### Node.js (with Auth Token)
`js
const {init} = require("@heyputer/puter.js/src/init.cjs"); // NODE JS ONLY
// or
import {init} from "@heyputer/puter.js/src/init.cjs";const puter = init(process.env.puterAuthToken); // uses your auth token
const puter2 = init(process.env.puterAuthToken2); // use some other auth token
`
Usage Example
After importing, you can use the global
puter object:`js
// Print a message
puter.print('Hello from Puter.js!');// Chat with GPT-5 nano
puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
puter.print(response);
});
`
Starter Templates
You can also use one of the following templates:
- Client-side projects: Angular, React, Next.js, Vue.js, Vanilla.js
- Node.js + Express: Node.js + Express template
Setting Custom Origins
By default puter.js uses the official Puter API and GUI origins. You can customize these origins by setting global variables before importing the SDK like so:`js
// For API origin
globalThis.PUTER_API_ORIGIN = 'https://custom-api.puter.com';
// For GUI origin
globalThis.PUTER_ORIGIN = 'https://custom-gui.puter.com';import {puter} from '@heyputer/puter.js'; // or however you import it for your env
``---
- Developer Site
- API Docs
- Live Demo
- Puter.com
- Discord
- Reddit
- X (Twitter)
Apache-2.0