# Connect to Galactica Snap

Before the Galactica Snap can be installed, we need to check that Metamask is available in the user's browser. This is similar to a [standard Metamask connection](https://docs.metamask.io/wallet/get-started/set-up-dev-environment).

If Metamask is not installed, you can forward the user with the connect button to the install page:

```typescript
export const InstallMetamaskButton = () => (
  <Link href="https://metamask.io/" target="_blank">
    <FlaskFox />
    <ButtonText>Install MetaMask</ButtonText>
  </Link>
);
```

With Metamask present, the user can connect to the Galactica Snap and install it if necessary (missing or outdated) with the following function:

```typescript
const defaultSnapOrigin = "npm:@galactica-corp/snap";

await window.ethereum.request({
  method: 'wallet_requestSnaps',
  params: {
    [defaultSnapOrigin]: {},
  },
});
```

You can verify if the Snap is installed:

```typescript
/**
 * Get the snap from MetaMask.
 *
 * @returns The snap object returned by the extension.
 */
export const getSnap = async (): Promise<Snap | undefined> => {
  try {
    const snaps = await window.ethereum.request({
      method: 'wallet_getSnaps',
    });

    return Object.values(snaps).find(
      (snap) => snap.id === defaultSnapOrigin,
    );
  } catch (error) {
    console.log('Failed to obtain installed snap', error);
    return undefined;
  }
};
```

Now you should be able to use Galactica specific functions through the snap using the [wallet\_invokeSnap method](https://docs.metamask.io/snaps/reference/rpc-api#wallet_invokesnap). See the next page for an example


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.galactica.com/galactica-developer-documentation/building-a-galactica-dapp/front-end/guided-example/connect-to-galactica-snap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
