Course contentsShow
← React
Lesson 1490 of 2,39637. React 19 and BeyondFree lesson

Action Permalinks

Understanding how action state can be serialized in URLs for shareable form submission results.

Action Permalinks

What you'll learn: How to encode action state in URLs so users can share or bookmark form submission results.

The Shareable State Problem

When a user submits a form and sees results (like search results, filtered data, or calculation outcomes), they often want to share that exact view with others or return to it later. Without permalinks, that state lives only in memory—refresh the page and it's gone.

Action Permalinks solve this by serializing the action's state into the URL, making the results shareable and bookmarkable.

How It Works

After an action completes, you encode the relevant state into the URL as query parameters or path segments:

const [state, submitAction, isPending] = useActionState(
  async (prevState, formData) => {
    const query = formData.get('search');
    const results = await searchProducts(query);
    
    // Update URL with the action result
    window.history.replaceState({}, '', `?q=${encodeURIComponent(query)}`);
    
    return { query, results };
  },
  { query: '', results: [] }
);

Now the URL reflects the search, and users can share yoursite.com?q=laptops to show others the same search results.

Reading on Load

To make permalinks work fully, read the URL on initial render:

const initialQuery = new URLSearchParams(window.location.search).get('q') || '';

This pattern turns ephemeral form results into permanent, shareable URLs—like how Google search URLs encode your query.

Key Takeaway: Action permalinks encode action state in URLs, transforming temporary form results into shareable, bookmarkable links that preserve the exact user experience.