---
page_source: https://juspay.io/in/docs/ec-headless/react-native/resources/prefetch
page_title: Prefetch
---


# Prefetch



HyperSDK uses a js engine to run critical business logic which enables seamless integrations and faster updates to the SDK.

**Prefetch API**  gets the latest business logic and keeps the SDK experience uniform for all users. This API can be triggered any number of times and only updates assets for critical requirements.



## Sample Code Snippets:
### Integration Sample:

#### React Code Snippet:

```react
HyperSdkReact.preFetch(JSON.stringify(preFetchPayload));
```

#### Java Code Snippet:

```java
HyperServices.preFetch(getApplicationContext(), payload);
```

#### Swift Code Snippet:

```swift
HyperServices.preFetch(payload)

```

#### Objective-C Code Snippet:

```objective-c
[HyperServices preFetch:payload];
```

### Payload:

#### JSON:
```json
{ 
    "service" : "in.juspay.hyperapi",
    "payload"  : { 
        "clientId" : "<Client Id>"
    }
}
```

#### Java:
```plaintext
boolean useBetaAssets = true; // If you want to use beta assets
String clientId =  "clientId"; // unique resource identifier
JSONObject payload = new JSONObject(); 
JSONObject innerPayload = new JSONObject();

try {
  //Setting clientId as nested to ensure uniformity across payloads
   innerPayload.put("clientId", clientId);
  //Ensuring proper nesting
   payload.put("payload", innerPayload);
  //service acts as a product refrence
   payload.put("service", "in.juspay.hyperapi"); 
} catch (JSONException e) {
   e.printStackTrace();
}
HyperServices.preFetch(getApplicationContext(), payload);
```

#### Swift:
```plaintext
let clientId = "clientId" //Unique resource identifier

//Setting clientId as nested to ensure uniformity across payloads
var innerPayload : [String:Any] = [:]
innerPayload["clientId"] = clientId

//Service acts as a product refrence
let payload = [
   "payload" : innerPayload,
   "service" : "in.juspay.hyperapi" 
] as [String: Any]
      
HyperServices.preFetch(payload)
```

#### Objective-C:
```plaintext
NSString *clientId = @"clientId"; //Unique resource identifier

//Setting clientId as nested to ensure uniformity across payloads
NSMutableDictionary *innerPayload = [NSMutableDictionary new];
innerPayload[@"clientId"] = clientId;

//Service acts as a product refrence
NSDictionary *payload = @{
   @"payload" : innerPayload,
   @"service" : @"in.juspay.hyperapi" 
};
      
[HyperServices preFetch:payload];
```

