chore: improve invitation flow, update project dependencies and documentation for Next.js 16 (#408)
* chore: update project dependencies and documentation for Next.js 16 - Upgraded Next.js from version 15 to 16 across various documentation files and components. - Updated references to Next.js 16 in AGENTS.md and CLAUDE.md for consistency. - Incremented application version to 2.21.0 in package.json. - Refactored identity setup components to improve user experience and added confirmation dialogs for authentication methods. - Enhanced invitation flow with new logic for handling user redirection and token generation. * refactor: streamline invitation flow in e2e tests - Simplified the invitation flow test by using a predefined email instead of generating a random one. - Removed unnecessary steps such as clearing cookies and reloading the page before user sign-up. - Enhanced clarity by eliminating commented-out code related to identity verification and user membership checks. * refactor: improve code readability in IdentitiesPage and UpdatePasswordForm components - Enhanced formatting of JSX elements in IdentitiesPage and UpdatePasswordForm for better readability. - Adjusted indentation and line breaks to maintain consistent coding style across components. * refactor: enhance LinkAccountsList component with user redirection logic - Updated the LinkAccountsList component to include a redirectToPath option in the useLinkIdentityWithProvider hook for improved user experience. - Removed redundant user hook declaration to streamline the code structure. * refactor: update account setup logic in JoinTeamAccountPage - Introduced a check for email-only authentication support to streamline account setup requirements. - Adjusted the conditions for determining if a new account should set up additional authentication methods, enhancing user experience for new users.
This commit is contained in:
committed by
GitHub
parent
ae404d8366
commit
fa2fa9a15c
@@ -1,13 +1,15 @@
|
||||
# Makerkit Guidelines
|
||||
|
||||
## Project Stack
|
||||
- Framework: Next.js 15 App Router, TypeScript, React, Node.js
|
||||
|
||||
- Framework: Next.js 16 App Router, TypeScript, React, Node.js
|
||||
- Backend: Supabase with Postgres
|
||||
- UI: Shadcn UI, Tailwind CSS
|
||||
- Key libraries: React Hook Form, React Query, Zod, Lucide React
|
||||
- Focus: Code clarity, Readability, Best practices, Maintainability
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
/apps/web/
|
||||
/app
|
||||
@@ -26,6 +28,7 @@
|
||||
## Core Principles
|
||||
|
||||
### Data Flow
|
||||
|
||||
1. Server Components
|
||||
- Use Supabase Client directly via `getSupabaseServerClient`
|
||||
- Handle errors with proper boundaries
|
||||
@@ -50,13 +53,14 @@
|
||||
queryFn: async () => {
|
||||
const { data } = await fetch('/api/notes');
|
||||
return data;
|
||||
}
|
||||
},
|
||||
});
|
||||
return { data, isLoading };
|
||||
}
|
||||
```
|
||||
|
||||
### Server Actions
|
||||
|
||||
- Name files as "server-actions.ts" in `_lib/server` folder
|
||||
- Export with "Action" suffix
|
||||
- Use `enhanceAction` with proper typing
|
||||
@@ -74,7 +78,7 @@
|
||||
{
|
||||
auth: true,
|
||||
schema: NoteSchema,
|
||||
}
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
@@ -86,6 +90,7 @@
|
||||
## Database & Security
|
||||
|
||||
### RLS Policies
|
||||
|
||||
- Strive to create a safe, robust, secure and consistent database schema
|
||||
- Always consider the compromises you need to make and explain them so I can make an educated decision. Follow up with the considerations make and explain them.
|
||||
- Enable RLS by default and propose the required RLS policies
|
||||
@@ -97,6 +102,7 @@
|
||||
## Forms Pattern
|
||||
|
||||
### 1. Schema Definition
|
||||
|
||||
```tsx
|
||||
// schema/note.schema.ts
|
||||
import { z } from 'zod';
|
||||
@@ -109,6 +115,7 @@ export const NoteSchema = z.object({
|
||||
```
|
||||
|
||||
### 2. Form Component
|
||||
|
||||
```tsx
|
||||
'use client';
|
||||
|
||||
@@ -116,7 +123,7 @@ export function NoteForm() {
|
||||
const [pending, startTransition] = useTransition();
|
||||
const form = useForm({
|
||||
resolver: zodResolver(NoteSchema),
|
||||
defaultValues: { title: '', content: '', category: 'personal' }
|
||||
defaultValues: { title: '', content: '', category: 'personal' },
|
||||
});
|
||||
|
||||
const onSubmit = (data: z.infer<typeof NoteSchema>) => {
|
||||
@@ -132,15 +139,18 @@ export function NoteForm() {
|
||||
|
||||
return (
|
||||
<Form {...form}>
|
||||
<FormField name="title" render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Title</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)} />
|
||||
<FormField
|
||||
name="title"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Title</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{/* Other fields */}
|
||||
</Form>
|
||||
);
|
||||
@@ -154,11 +164,12 @@ export function NoteForm() {
|
||||
- Consider the unhappy path and handle errors appropriately
|
||||
|
||||
### Structured Logging
|
||||
|
||||
```tsx
|
||||
const ctx = {
|
||||
name: 'create-note',
|
||||
userId: user.id,
|
||||
noteId: note.id
|
||||
noteId: note.id,
|
||||
};
|
||||
|
||||
logger.info(ctx, 'Creating new note...');
|
||||
@@ -177,13 +188,14 @@ try {
|
||||
In client components, we can use the `useUserWorkspace` hook to access the user's workspace data.
|
||||
|
||||
### Personal Account
|
||||
|
||||
```tsx
|
||||
'use client';
|
||||
|
||||
function PersonalDashboard() {
|
||||
const { workspace, user } = useUserWorkspace();
|
||||
if (!workspace) return null;
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Welcome, {user.email}</h1>
|
||||
@@ -194,6 +206,7 @@ function PersonalDashboard() {
|
||||
```
|
||||
|
||||
### Team Account
|
||||
|
||||
In client components, we can use the `useTeamAccountWorkspace` hook to access the team account's workspace data. It only works under the `/home/[account]` route.
|
||||
|
||||
```tsx
|
||||
@@ -201,7 +214,7 @@ In client components, we can use the `useTeamAccountWorkspace` hook to access th
|
||||
|
||||
function TeamDashboard() {
|
||||
const { account, user } = useTeamAccountWorkspace();
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{account.name}</h1>
|
||||
@@ -220,6 +233,7 @@ function TeamDashboard() {
|
||||
## Creating Pages
|
||||
|
||||
When creating new pages ensure:
|
||||
|
||||
- The page is exported using `withI18n(Page)` to enable i18n.
|
||||
- The page has the required and correct metadata using the `metadata` or `generateMetadata` function.
|
||||
- Don't worry about authentication, it's handled in the middleware.
|
||||
|
||||
Reference in New Issue
Block a user