Nextbase Docs
Nextbase Docs
HomeBlogWelcome to Nextbase v3!Getting Started with NextBaseQuick setup
Admin Panel GuideAsynchronous Data Fetching GuideAuthenticationCreating Admin Panel PageCreating Docs PageCreating in-app notificationsCreating a new Supabase tableCreating Protected PageCreating Public Dynamic PageCreating Public Static PageHandling Realtime Data With SupabaseManaging UsersMutating Data With SupabaseOptimizing Data Operations in Next.js 14 and SupabaseRow Level SecurityStripe Setup in Nextbase UltimateWriting Integration Tests with PlaywrightWriting Unit Tests with Vitest
Guides

Optimizing Data Operations in Next.js 14 and Supabase

Learn how to efficiently fetch and mutate data in Next.js 14 and Supabase using server components, useToastMutation, and Supabase real-time APIs.

In this guide, we'll explore best practices for fetching and mutating data in Nextbase applications, focusing on performance and efficiency.

Server-Side Data Fetching

Prefer fetching data for components on the server using server components. This approach utilizes the higher CPU power of servers and minimizes bundle sizes for the data fetching operation.

Mutations with useToastMutation

For mutations, use the useToastMutation hook. This allows for direct server-side mutations while providing user feedback through toast notifications.

Realtime Queries with Supabase

For realtime queries, such as notifications, use Supabase's realtime APIs directly on the client side.

Avoiding useState for Data Fetching

Avoid using useState for most data fetching operations. Instead, either use server components and fetch data within them, or use useQuery if you really need to, but you generally shouldn't need to use useState.

By following these guidelines, you can optimize data operations in your Nextbase applications for better performance and user experience.

Mutating Data With Supabase

Learn how to mutate data asynchronously in Supabase using server actions and react query

Row Level Security

Row Level Security in NextBase is a powerful feature that allows you to control access to rows in your database based on the user who is querying the data.

On this page

Server-Side Data FetchingMutations with useToastMutationRealtime Queries with SupabaseAvoiding useState for Data Fetching