Magic for Flutter

Magic for Flutter

New to Magic?

Create a fully-functional Magic auth demo in minutes.

Build a demo


The Magic Flutter SDK is distributed on the package manager. This is your entry-point to secure, passwordless authentication for your iOS or Android-based Flutter app. This guide will cover some important topics for getting started with client-side APIs and to make the most of Magic's features.

Magic can support either server-based or serverless applications. It is up to the developers to implement the Admin SDK to validate the DID Token.


Add magic_sdk to your pubspec.yaml:

02  flutter:
03    sdk: flutter
04  magic_sdk: ^2.0.0

Run the following command to install dependencies

01$ dart pub get

#Create an SDK Instance

In main.dart, instantiate Magic with your publishable key

01void main() {
02  runApp(const MyApp());
04  Magic.instance = Magic("YOUR_PUBLISHABLE_KEY");

Use Stack in the top level and add Magic.instance.relayer to the children of Stack to ensure the best performance

01class MyApp extends StatelessWidget {
02  const MyApp({Key? key}) : super(key: key);
04  // This widget is the root of your application.
06  Widget build(BuildContext context) {
07    return MaterialApp(
08        home: Stack(children: [ // Use Stack() here
09          MaterialApp(
10            title: 'Magic Demo',
11            home: const LoginPage(),
12          ),
13          Magic.instance.relayer // Insert Magic relayer here
14        ]));
15  }

Server-side SDKs?

Integrate Magic with your existing backend.

Did you find what you were looking for?

Did you find what you were looking for?