Astro

This example ) demonstrates how to use WunderGraph with Astro .

Installation

1
npx create-wundergraph-app --example astro

Configuration

The configuration for WunderGraph is located in the .wundergraph directory.

For this example we use the Countries GraphQL API .

1
2
3
4
5
6
7
8
9
10
11
// ...
const countries = introspect.graphql({
apiNamespace: 'countries',
url: 'https://countries.trevorblades.com/',
});
// configureWunderGraph emits the configuration
configureWunderGraphApplication({
apis: [countries],
// ...
});

Query data

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
import Layout from '../layouts/Layout.astro';
import Card from '../components/Card.astro';
import { client } from '../lib/wundergraph';
const { data } = await client.query({
operationName: 'Continents',
})
---
<Layout title="Welcome to Astro.">
<main>
<h1>Welcome to <span class="text-gradient">Astro</span> + <span class="text-gradient">WunderGraph</span></h1>
<p class="instructions">
To get started, open the directory <code>src/pages</code> in your project.<br />
<strong>Code Challenge:</strong> Tweak the "Welcome to Astro + WunderGraph" message above.<br /><br />
<a href="https://docs.wundergraph.com">WunderGraph Docs</a> - <a href="https://docs.astro.build/">Astro Docs</a>
</p>
<ul role="list" class="link-card-grid">
{data && data.countries_continents.map((continent) => (
<Card
href={`/continents/${continent.code}`}
title={continent.name}
body={continent.name}
/>
))}
</ul>
</main>
</Layout>

Learn more

Deploy to WunderGraph Cloud

The easiest way to deploy your WunderGraph app is to use WunderGraph Cloud. Enable the Vercel integration to deploy the Vite frontend to Vercel.

Deploy to WunderGraph

Was this article helpful to you?
Provide feedback

Edit this page