Docs
Auth

Celest Auth

Celest currently supports email-based authentication via one-time passcodes. This is a simple and secure way to authenticate users in your app without needing to worry about passwords.

💡

We are working on adding social sign-in and passkeys in future releases. If you have a specific use case you'd like to see, please let us know by creating an issue (opens in a new tab).

Adding Auth to your Celest project takes 5 lines of code. In your project.dart file, add the following code:

celest/project.dart
import 'package:celest/celest.dart';
 
const project = /* .. */;
 
const auth = Auth(
  providers: [
    AuthProvider.email(),
  ],
);

That's it! When you run celest start, Celest will automatically generate an Auth client for you to use in your Flutter app.

Signing In

To sign in a user, you can use the authenticate method on the celest.auth object. It's called authenticate because there is no longer a distinction between signing in or signing up! If the user doesn't exist, they will be created.

final flow = await celest.auth.email.authenticate(
  email: 'dillon@celest.dev',
);
 
// Prompt user for OTP code sent to the email
 
final user = await flow.verify(otpCode: '123456');
print('User signed in: ${user.id}');

A full example of a typical auth flow can be found in our repo (opens in a new tab).

Authorizing your functions

Once a user is signed in, they can access functions marked @authenticated. To learn more about authorizing your functions, check out Authorizing functions.