# Remix Integration

> Build a full-stack Remix app with Sendable WhatsApp API.

Source: https://wav1.recrav.com/docs/quickstart/nodejs/remix

## Project Setup [#project-setup]

```bash
npx create-remix@latest my-sendable-app
cd my-sendable-app
```

## Environment Setup [#environment-setup]

Create `.env`:

```bash
SENDABLE_API_KEY=your_api_key_here
```

## Loader for Sending Messages [#loader-for-sending-messages]

Create `app/routes/api.send-message.ts`:

```typescript
import type { ActionFunctionArgs } from '@remix-run/node'

export async function action({ request }: ActionFunctionArgs) {
  const { to, text } = await request.json()

  const response = await fetch('https://api.sendable.dev/messages/send', {
    method: 'POST',
    headers: {
      'x-api-key': process.env.SENDABLE_API_KEY!,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ to, text }),
  })

  return response.json()
}
```

## Component [#component]

Create `app/components/MessageForm.tsx`:

```typescript
import { Form, useActionData } from '@remix-run/react'

export function MessageForm() {
  const actionData = useActionData()

  return (
    <Form method="post" action="/api/send-message">
      <input name="to" placeholder="Phone number" />
      <textarea name="text" placeholder="Message" />
      <button type="submit">Send</button>
      {actionData?.success && <p>Sent!</p>}
    </Form>
  )
}
```

See full example on [GitHub](https://github.com/sendablelabs/examples/tree/main/remix).
