Replace Express, Mongo, Postgres, Kafka, S3, Socket.io, Auth0 and more with standard APIs already built into TypeScript.
Rather than adding new opinionated APIs for functionality like persistence, streaming and blob storage, Freestyle leverages the APIs already built into ecmascript standards.
Put @cloudstate on any class and its properties will be stored forever and available in any request.
@cloudstate
class CloudEmailList {
emails: string[] = [];
add(email: string) {
this.emails.push(email);
}
list() {
return this.emails;
}
}
Freestyle is built to encourage open source collaboration. Rather than relying on external services for things like authentication, Freestyle provides a foundation that full stack packages can be built on top of.
Instead of using an auth provider like Auth0, you can use our open source freestyle-auth package.
import { PasskeyAuthentication } from "freestyle-auth";
@cloudstate
class AuthenticationCS extends PasskeyAuthentication {
static id = "auth" as const;
override _createUser() {
return new UserCS(crypto.randomUUID(), "", "");
}
}
@cloudstate
export class UserCS {
constructor(
public id: string,
public username: string,
public image: ImageCS,
public displayName?: string
) {}
_assertSelf() {
const auth = useLocal(AuthenticationCS);
const user = auth.getCurrentUser();
if (user !== this) throw new Error("You do not have permission for this operation.");
}
setDisplayName(displayName: string) {
this._assertSelf();
this.displayName = displayName;
}
}
}
import { PasskeyAuthenticationModal } from "freestyle-auth/react";
export function SignInPage() {
const auth = useCloud<typeof AuthenticationCS>("auth");
return (
<PasskeyAuthenticationModal
auth={auth}
onSignedIn={() => {
window.location.href = "/dashboard";
}}
/>
);
}
All pure TypeScript. No config needed.
npx freestyle deploy
Use native TypeScript APIs everywhere, instead of integrating cloud boilerplate, so you can finally focus on writing business logic.