Data APIs

Response helpers

Edit this page

Redirect

Signature: redirect(path, options) Redirects to the next route

const getUser = cache(() => {
const user = await api.getCurrentUser()
if (!user) throw redirect("/login");
return user;
})

Reload

Signature: reload(options)

Reloads the data on the current page

const getTodo = cache(async (id: number) => {
const todo = await fetchTodo(id);
return todo;
}, "todo");
const updateTodo = action(async (todo: Todo) => {
await updateTodo(todo.id, todo);
reload({ revalidate: getTodo.keyFor(id) });
});
Report an issue with this page