---
title: How to Restore a Keypair or Signer
description: "Learn how to restore keypairs from a secret key on Solana."
---

If you have an existing secret key, you can restore your Keypair from it. This
allows you to access your wallet and sign transactions in your dApp.

<Callout type="warn">
  Handle secret keys with care: never embed them in client-side code or commit
  them to source control. For backend services in production, use a
  key-management backend instead of a raw secret key — see [Signing in
  Production](/docs/core/transactions/signing-in-production).
</Callout>

## From Bytes

<CodeTabs storage="cookbook" flags="r">

```ts !! title="Kit" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-bytes-kit.ts#region=from-bytes

```

```ts !! title="Web3.js v3" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-bytes-web3v3.ts#region=from-bytes

```

```rust !! title="Rust" file=packages/docs-examples/cookbook/wallets/restore-keypair/rust/src/bin/from-bytes.rs#region=from-bytes

```

```py !! title="Python" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-bytes-python.py#region=from-bytes

```

```go !! title="Go" file=packages/docs-examples/cookbook/wallets/restore-keypair/go-from-bytes/main.go#region=from-bytes

```

```ts !! title="Web3.js (legacy)" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-bytes-legacy.ts#region=from-bytes

```

</CodeTabs>

## From Base58 String

<CodeTabs storage="cookbook" flags="r">

```ts !! title="Kit" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-base58-kit.ts#region=from-base58

```

```ts !! title="Web3.js v3" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-base58-web3v3.ts#region=from-base58

```

```rust !! title="Rust" file=packages/docs-examples/cookbook/wallets/restore-keypair/rust/src/bin/from-base58.rs#region=from-base58

```

```py !! title="Python" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-base58-python.py#region=from-base58

```

```go !! title="Go" file=packages/docs-examples/cookbook/wallets/restore-keypair/go-from-base58/main.go#region=from-base58

```

```ts !! title="Web3.js (legacy)" file=packages/docs-examples/cookbook/wallets/restore-keypair/from-base58-legacy.ts#region=from-base58

```

</CodeTabs>
