useFetch — SSR-compatible composable. $fetch — direct HTTP client.
useFetch:
$fetch:
1<script setup>2// useFetch - auto SSR3const { data } = await useFetch("/api/posts")45// $fetch - manual6const data = await $fetch("/api/posts")78// useAsyncData + $fetch9const { data } = await useAsyncData("posts", () => {10 return $fetch("/api/posts")11})12</script>
When to use: