* feat: add validation error type * feat: move subscribe to top-level * fix: wrong import
The fal-serverless JS Client
About the project
The fal-serverless JS/TS Client is a powerful and easy-to-use JavaScript and TypeScript library that allows you to effortlessly integrate and run your fal serverless functions in your Web, Node.js and React Native applications.
The project is written in TypeScript, so developers get type-safety out-of-the-box.
Getting Started
The serverless-js library is a client for the fal serverless Python functions. Check the quickstart guide in order to create your functions.
Library
The client library is designed as a lightweight layer on top of the platform standards, such as fetch and WebSocket, ensuring smooth integration with your existing codebase.
It also handle platform differences, so it work seamlessly across different JS runtimes.
Note
Make sure you followed the fal-serverless getting started so you get your credentials and register your functions.
- First you need to configure your credentials:
import * as fal from '@fal-ai/serverless-js';
fal.config({
// can also be auto-configured using environment variables
credentials: "FAL_KEY_ID:FAL_KEY_SECRET",
});
- Get your function id and run it:
const result = await fal.run('my-function-id');
The result type depends on the result of your Python function, types are mapped to their equivalent types in JS.
The example Next.js app
You can find a minimal Next.js + fal application examples in apps/demo-app/.
- Run
npm installon the repository root. - Run
npx nx serve demo-appto start the Next.js app.
The Next.js fal proxy
The Next.js + fal integration provides you with a proxy that allows you to run your functions directly from the browser without exposing your fal credentials.
- Instal it with
npm install --save @fal-ai/serverless-nextjs - Add the proxy as an API endpoint of your app, see an example here in apps/demo-app/pages/api/_fal/proxy.ts
Roadmap
See the open feature requests for a list of proposed features and join the discussion.
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Make sure you read our Code of Conduct
- Fork the project and clone your fork
- Setup the local environment with
npm install - Create a feature branch (
git checkout -b feature/add-cool-thing) or a bugfix branch (git checkout -b fix/smash-that-bug) - Commit the changes (
git commit -m 'feat(client): added a cool thing') - use conventional commits - Push to the branch (
git push --set-upstream origin feature/add-cool-thing) - Open a Pull Request
Check the good first issue queue, your contribution will be welcome!
License
Distributed under the MIT License. See LICENSE for more information.