Vibe code a what3words integration
Use AI tools like Replit, Lovable and ChatGPT to add what3words to the tools, apps and planners you use every day, without coding skills.

There are now a number of AI tools like Replit, Lovable and ChatGPT that allow you to create and update webpages or apps just using prompts and written requests in your normal language, without a developer or coding skills. It’s being called ‘vibe coding’.
So now, with support of AI, you can integrate what3words into the tools, apps and planners you use every day without any technical knowledge.
Watch a demo
How to give it a go
- Grab a what3words API key and sign up for an account.
- Open up your chosen AI tool. We’ve used Replit, but there are others available.
- Guide it with prompts to create the integration you want.
Ready-to-go guides for the what3words API
what3words guides to attach to your Replit Agent prompt midway through a project
# what3words search box (CDN Edition)
### Replit • Modern Web App (React + Vite + TypeScript)
> **STOP — YOU NEED AN API KEY FIRST!**
> 1. Open the **Secrets** tab in Replit.
> 2. Click **+ New secret**
> * **Key:** `VITE_W3W_API_KEY`
> * **Value:** *your developer key* from <https://developer.what3words.com>
> 3. Press **Add secret**.
>
> The component will **not work** until this key is set.
---
## 1 · Create or open a Modern Web App
*Choose “Modern web app (React + Node.js)” when you create the Repl.*
Replit scaffolds a folder called **`client/`** that holds the React frontend.
---
## 2 · Add the what3words component via CDN (no npm)
1. Open **`client/index.html`**.
2. Just before `</head>` paste these two lines:
```html
<!-- what3words web-component bundle -->
<script async type="module"
src="https://cdn.what3words.com/javascript-components@5.0.0/dist/what3words/what3words.esm.js"></script>
<script nomodule
src="https://cdn.what3words.com/javascript-components@5.0.0/dist/what3words/what3words.js"></script>
```
That’s it — no package install, no Vite config.
---
## 3 · Replace `client/src/App.tsx` with the demo
```tsx
import { useRef, useEffect, useState } from "react";
// ⬇ pulled from Replit Secrets (must be set!)
const API_KEY = import.meta.env.VITE_W3W_API_KEY as string;
export default function App() {
const [words, setWords] = useState("");
const [coords, setCoords] =
useState<{ lat: number; lng: number } | null>(null);
const ref = useRef<HTMLWhat3wordsAutosuggestElement>(null);
// Alert if the key is missing
useEffect(() => {
if (!API_KEY) {
alert(
"what3words API key is missing!\n" +
"Add it in Secrets as VITE_W3W_API_KEY and restart."
);
}
}, []);
// Listen for selection events
useEffect(() => {
const el = ref.current;
if (!el) return;
const handler = (e: any) => {
const w = e.detail.suggestion.words as string;
setWords(w);
setCoords(null);
fetch(
`https://api.what3words.com/v3/convert-to-coordinates?words=${w}&key=${API_KEY}`
)
.then((r) => r.json())
.then((d) => setCoords(d.coordinates))
.catch(console.error);
};
el.addEventListener("selected_suggestion", handler);
return () => el.removeEventListener("selected_suggestion", handler);
}, []);
return (
<main style={{ fontFamily: "system-ui", padding: "4rem 1rem", color: "#0A3049" }}>
<h1 style={{ textAlign: "center", marginBottom: "0.25rem" }}>what3words search box</h1>
<p style={{ textAlign: "center", fontSize: 18 }}>Enter a what3words address</p>
{/* lower-case tag provided by the CDN bundle */}
<what3words-autosuggest api_key={API_KEY} ref={ref}>
<input
type="text"
placeholder="e.g. ///filled.count.soap"
autoComplete="off"
style={{
width: "100%",
maxWidth: 500,
padding: "0.75rem",
fontSize: 18,
margin: "1rem auto",
display: "block",
border: "2px solid #0A3049",
borderRadius: 6,
outlineColor: "#E11F26",
}}
/>
</what3words-autosuggest>
<div
style={{
border: "1px dashed #0A3049",
minHeight: 80,
maxWidth: 500,
margin: "2rem auto",
display: "grid",
placeItems: "center",
borderRadius: 8,
fontSize: 16,
}}
>
{words
? coords
? `${words} → ${coords.lat}, ${coords.lng}`
: "Fetching coordinates…"
: "Your what3words address and the corresponding GPS coordinates will appear here"}
</div>
</main>
);
}
```
---
## 4 · Run & test
1. Press **Run**.
2. In the preview, type **`filled.count.soap`**.
3. A dropdown appears → pick **filled.count.soap**.
4. The box below shows the three words, then the coordinates.
---
## Troubleshooting
| Issue | Checklist |
|-------|-----------|
| **No suggestions appear** | • Is `VITE_W3W_API_KEY` set in Secrets?<br>• Key valid in your W3W dashboard?<br>• Type at least two words + part of a third. |
| **“Loading what3words API…” never disappears** | • Check the CDN `<script>` URLs are pasted exactly as shown. |
| **Alert: API key missing** | • Add the secret, then **stop & Run** again so Vite reloads the env vars. |
That’s all — no bundler tweaks, no extra packages.
Enjoy instant what3words address search in your Replit app!
# Quickstart: Build a what3words Map in Replit (React, **CDN build**)
## Overview
Embed the what3words Map component in a fresh React Replit *without editing `vite.config`*. We load the component directly from the CDN so Vite’s dependency optimiser never touches it.
---
## 1 · Create a React project
1. Log in to Replit and click **➕ Create Repl**.
2. Choose **React (Vite)** *or* **Modern Web App** – the CDN route works with either template.
3. Name it `w3w-map-cdn` and hit **Create Repl**.
> **Why CDN?** Templates often lock or omit `vite.config`; loading the component from the CDN sidesteps Vite’s pre‑bundling step entirely.
---
## 2 · Load the what3words components from the CDN
Open **public/index.html** and, just before `</head>`, add:
```html
<!-- what3words custom elements -->
<script type="module" defer
src="https://cdn.what3words.com/javascript-components@5.0.0/dist/what3words/what3words.esm.js"></script>
<script nomodule defer
src="https://cdn.what3words.com/javascript-components@5.0.0/dist/what3words/what3words.js"></script>
```
---
## 3 · Reset global styles (stop scrollbars)
Add to **`src/index.css`** (or global stylesheet):
```css
html, body, #root {
height: 100%; /* let the React root fill the viewport */
margin: 0; /* remove default body margin that causes a scrollbar */
}
body {
overflow: hidden; /* prevent the map from scrolling the page */
-webkit-overflow-scrolling: touch;
}
```
---
## 4 · Store your API keys as secrets
1. In Replit’s sidebar click **Secrets** 🔑
2. Add with the `VITE_` prefix:
- `VITE_W3W_API_KEY` → *your‑w3w‑key*
- `VITE_GOOGLE_MAP_API_KEY` → *your‑google‑maps‑key*
3. Restart the dev server so Vite exposes them.
---
## 5 · Create the Map component
Add `src/Map.jsx`:
```jsx
export default function W3WMap() {
return (
<what3words-map
id="w3w-map"
api_key={import.meta.env.VITE_W3W_API_KEY}
map_api_key={import.meta.env.VITE_GOOGLE_MAP_API_KEY}
words="filled.count.soap"
disable_default_ui
fullscreen_control
current_location_control_position="9"
fullscreen_control_position="3"
search_control_position="2"
>
{/* map canvas fills exactly the visible viewport on mobile & desktop */}
<div slot="map" style={{ width: "100vw", height: "100dvh" }}></div>
{/* centred, responsive search bar */}
<div
slot="search-control"
style={{
position: "absolute",
top: "16px",
left: "50%",
transform: "translateX(-50%)",
zIndex: 1000,
}}
>
<what3words-autosuggest>
<input
type="text"
placeholder="Search what3words address"
autoComplete="off"
style={{
width: "clamp(260px, 32ch, 380px)",
padding: "12px 16px",
borderRadius: "6px",
border: "1px solid #ccc",
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
fontSize: "14px",
boxSizing: "border-box",
outline: "none",
}}
/>
</what3words-autosuggest>
</div>
</what3words-map>
);
}
```
> **Why `height:100dvh`?** The *dynamic* viewport unit always equals the space actually visible, so the map never hides behind browser chrome or causes scrollbars.
---
## 6 · Render the map
Replace `src/App.jsx` with:
```jsx
import W3WMap from "./Map";
export default function App() {
return <W3WMap />;
}
```
---
## 7 · Run & test
Click **Run** ▶️ or run `npm run dev`. The preview shows a full‑height map with a centred search bar and **no white space or scrollbars** on desktop or mobile.
---
## 8 · Customise
| Feature | Example |
|---------|---------|
| Language | `<what3words-map language="fr">` |
| Map type | `map_type="satellite"` |
| Event listener | `mapEl.addEventListener('wordsChanged', e => console.log(e.detail.words));` |
---
## 9 · Troubleshooting
| Symptom | Fix |
|---------|-----|
| Grey tiles | Check Google Maps key & HTTP referrer restrictions |
| `api_key` error | Ensure secrets start with `VITE_` & restart server |
| Dropdown hidden | Give `<what3words-autosuggest>` a higher `z-index` |
---
## Further resources
- **Using the Web Map Component** tutorial
- **@what3words/javascript-components** CDN reference
- GitHub samples (React & Vanilla JS)Replit templates to use if you’re starting a Replit project
what3words search box: enable your users to enter a what3words address in any language. The AutoSuggest component will show 3 suggestions. When the user clicks one, it will convert the what3words address to coordinates (lat, long). Open the what3words search box template
what3words search box on map: add a what3words search box on an interactive map. By clicking on a what3words square on the map, a what3words address will appear. Open the what3words search box on a map template
API key sign-up process
- Select an API plan.
- Log in or create an API account.
- Create an API key.
To find your API key, you can log into your what3words API account.
