---
title: "Data Fetching and Mutation"
description: "Data fetching and mutation allow your application to retrieve information from backend services or APIs and securely submit form updates or modifications. This page explains how data retrieval hand..."
last_updated: "2026-10-12T06:40:49.088149+00:00"
canonical_url: "https://www.doc0.dev/docs/8f4009b0-65bd-4480-9b00-e201f0914bb3/guide/core-features/data-fetching-and-mutation"
---

## Overview

### Introduction to Data Management

Data fetching and mutation allow your application to retrieve information from backend services or APIs and securely submit form updates or modifications. This page explains how data retrieval handles caching, prefetching, and how forms process submissions safely in your application.

### Key Concepts

Understanding how data flows and gets cached will help you build faster, more reliable web pages.

* **Prefetching**: The system automatically loads data for links or navigation forms when they appear on your screen (viewport), so pages load instantly when clicked.
* **Caching**: Retrieved data and static page shells are stored in memory or on disk to serve subsequent requests faster without hitting your backend services repeatedly.
* **Server Actions**: Secure functions executed on the server to handle form submissions and data updates without exposing sensitive database credentials to the browser.

---

## Fetching Data and Handling Responses

### Data Retrieval Workflow

When your application requests information, the system handles network requests, retries, and caching automatically behind the scenes.

1. A component requests data or a user navigates to a new page route.
2. The system checks local caches and prefetch stores for existing valid data.
3. If data is missing or stale, a network request is dispatched to fetch the latest response.
4. Responses are processed, parsed, and stored in the cache for future requests.

> [!NOTE]
> If a network request fails due to temporary connectivity issues, automatic retries will be attempted for server-rendered data to ensure reliability.

---

## Submitting Form Updates Safely

### Submitting a Form

Forms can navigate to a destination URL or execute secure mutations when submitted. 

1. Fill out the form fields in your user interface.
2. Click the submit button.
3. The application intercepts the native submission, validates the action target and parameters, and prevents default page reloads when using soft navigation.
4. The router handles the transition smoothly, updating your application state and history stack.

> [!WARNING]
> When using a string-based `action` URL on a form, file inputs are not supported because files cannot be encoded directly as search parameters. Use a function-based action if your form requires file uploads.

---

## Configuration Options

### Form Property Reference

When configuring forms and data requests, certain properties control navigation, caching behavior, and replacement strategies.

| Property | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `action` | `string` \| `function` | Required | The URL path to navigate to or the server function to execute upon submission. |
| `prefetch` | `boolean` \| `null` | `null` | Controls whether route data is prefetched when the form enters the viewport. |
| `replace` | `boolean` | `false` | Replaces the current history state instead of pushing a new entry to the stack. |
| `scroll` | `boolean` | `true` | Controls whether the window scrolls to the top of the page after navigation. |

> [!TIP]
> Setting `prefetch={false}` disables automatic background prefetching for forms that you do not expect users to submit frequently, saving network bandwidth.

## Related

- [Caching and Revalidation](https://www.doc0.dev/docs/8f4009b0-65bd-4480-9b00-e201f0914bb3/guide/how-to-guides/caching-and-revalidation)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/8f4009b0-65bd-4480-9b00-e201f0914bb3/llms.txt) for all pages in this wiki.
