mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated examples and guides to use Supabase publishable (client) keys instead of anon keys for client-side usage across frameworks and platforms. * Renamed environment variable examples and .env templates to reflect publishable key naming. * Adjusted sample requests and client-init examples to send/use the publishable key via the apikey header where applicable. * Updated references from service_role to secret for server-side credential guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: fadymak <fady@fadymak.com>
65 lines
1.5 KiB
Dart
65 lines
1.5 KiB
Dart
import 'package:canvas/auth/login_page.dart';
|
|
import 'package:canvas/canvas/canvas_page.dart';
|
|
import 'package:canvas/project/projects_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_web_plugins/url_strategy.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:supabase_auth_ui/supabase_auth_ui.dart';
|
|
|
|
void main() async {
|
|
usePathUrlStrategy();
|
|
|
|
await Supabase.initialize(
|
|
url: 'YOUR_SUPABASE_URL',
|
|
publishableKey: 'YOUR_SUPABASE_PUBLISHABLE_KEY',
|
|
);
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
final supabase = Supabase.instance.client;
|
|
|
|
final _router = GoRouter(
|
|
initialLocation: '/signin',
|
|
routes: [
|
|
GoRoute(
|
|
path: '/signin',
|
|
builder: (context, state) => const LoginPage(),
|
|
),
|
|
GoRoute(
|
|
path: '/projects',
|
|
builder: (context, state) => const ProjectsPage(),
|
|
),
|
|
GoRoute(
|
|
path: '/canvas/:projectId',
|
|
builder: (context, state) =>
|
|
CanvasPage(state.pathParameters['projectId']!),
|
|
),
|
|
],
|
|
redirect: (BuildContext context, GoRouterState state) {
|
|
final isSignedIn = supabase.auth.currentSession != null;
|
|
if (state.path != '/signin') {
|
|
if (!isSignedIn) {
|
|
return '/signin';
|
|
}
|
|
} else {
|
|
if (isSignedIn) {
|
|
return '/projects';
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
);
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp.router(
|
|
title: 'Figma Clone',
|
|
debugShowCheckedModeBanner: false,
|
|
routerConfig: _router,
|
|
);
|
|
}
|
|
}
|