---
title: Initialization
slug: web-view-sdk-initialization
createdAt: 2026-11-03T10:14:14.015Z
---

Start the SDK once with your bot key and market, for example when your app launches. `start` does not load the chat yet: the chat page is created the first time the chat is shown. It does start the SDK's usage metrics and error reports, so if your app needs the user's consent for those, call `start` once the user has given it, see [Privacy and Data](docId\:gyIQwGQKBb66C-HH3gIpp)

## Start the SDK

::::Tabs
:::Tab{title="iOS"}
```swift
import KindlyWebView

KindlyWebViewSDK.start(botKey: "YOUR_BOT_KEY", languageCode: "en", market: "general")
```

Call it from `application(_:didFinishLaunchingWithOptions:)`, from your SwiftUI `App`'s initializer or wherever your app starts. Every member of `KindlyWebViewSDK` is static and can be called from any thread

A value in the wrong format is refused with an error in the log, and the call does nothing
:::

:::Tab{title="Android"}
```kotlin
import ai.kindly.webview.KindlyWebViewSDK

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        KindlyWebViewSDK.start(
            application = this,
            botKey = "YOUR_BOT_KEY",
            languageCode = "en",
            market = "general",
        )
    }
}
```

Register the class with `android:name=".App"` on the `<application>` element of your manifest. Every function can be called from any thread, and the SDK moves to the main thread itself

A value in the wrong format is refused with an error in the log, and the call does nothing
:::

:::Tab{title="Flutter"}
```dart
import 'package:flutter/widgets.dart';
import 'package:kindly_webview/kindly_webview.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await KindlyWebViewSDK.start(botKey: 'YOUR_BOT_KEY', market: 'general', languageCode: 'en');
  runApp(const MyApp());
}
```

`WidgetsFlutterBinding.ensureInitialized()` lets a plugin call run before `runApp`. A value that is blank or in the wrong format throws an `ArgumentError` naming it, before anything changes, the auth callbacks included

The auth and link callbacks reach the Flutter engine whose Dart code last called `start`. An engine that never calls `start`, such as the background engine a messaging or work manager plugin creates, never receives them. After a hot restart, call `start` and `setDelegate` again so the new isolate's callbacks are registered. When the engine that called `start` goes away, the chat gets no token and links open outside the app until another engine calls `start`
:::

:::Tab{title="React Native"}
```typescript
import { KindlyWebViewSDK } from '@kindly-ai/react-native-webview';

await KindlyWebViewSDK.start({
  botKey: 'YOUR_BOT_KEY',
  market: 'general',
  languageCode: 'en',
});
```

A value in the wrong format rejects with `INVALID_ARGUMENT` before anything reaches the native SDK

The package answers the native SDK's requests for tokens and link decisions from the JavaScript runtime that is running. After a reload, call `start` and `setDelegate` again, as your app's startup code normally does: until then the chat gets no token and links open outside the app
:::
::::

`languageCode` defaults to `en`. The bot key, market and language code are trimmed first. A bot key is 8 to 64 letters, digits and hyphens, a market 1 to 64 letters, digits, `_` and `-`, and a language code looks like `en`, `nb` or `pt-BR`. The market must be one configured for the bot, see [Markets](docId\:hY7NowSOuz-mdL-_zIZeL)

## Calling start again

Calling `start` again with the same bot key and market keeps the live chat and replaces only the language and the auth provider. The language applies to the next chat page; to switch the live chat, pass a language when you [Launch Chat](docId\:Yjruacdl_gPttkM6yK-4V). A call without an auth provider leaves the chat without one, so pass it on every call

A different bot key or market closes the chat and starts over. The old conversation stays stored for when you switch back

## Authenticated chats

Pass an auth provider to `start` when the chat should know who your user is, see [Authentication](docId\:ObaH52zBKe08oBMXxiXu3)
