Edge Functions

Edge Functions allow you to deliver content to your site's visitors with speed and personalization. They are deployed globally on Vercel's Edge Network and enable you to move server-side logic to the Edge, close to your visitors.


<script setup>
const { data: info } = await useAsyncData(() =>
  globalThis.$fetch('/api/info', {
    headers: useRequestHeaders(['x-forwarded-for', 'x-vercel-ip-city']),
const generatedAt = useState(() => new Date().toISOString());

    <div>Hello from the Edge!</div>
      Your City: <span>{{ info.city }}</span>
      Your IP address: <span>{{ info.ip }}</span>
      Generated at: <span>{{ generatedAt }}</span>


export default eventHandler((event) => {
  const cityHeader = event.req.headers['x-vercel-ip-city'] as string;
  const city = cityHeader ? decodeURIComponent(cityHeader) : '-';
  const ipHeader = event.req.headers['x-forwarded-for'] as string;
  const ip = ipHeader ? ipHeader.split(',')[0] : '-';

  return {


Hello from the Edge!
Your City: -
Your IP address:
Generated at: 2024-06-22T13:09:38.497Z