
Security News
Inside Lodash’s Security Reset and Maintenance Reboot
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.
@developmentseed/stac-react
Advanced tools
React hooks to build front-end applications for STAC APIs.
Note: stac-react is in early development, the API will likely break in future versions.
TBD
Initialises a STAC-API client. Pass the instance to the React hooks as documented below.
import { StacApi, useCollections } from "stac-react";
function CollectionList() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const { collections } = useCollections(stacApi);
return (
<ul>
{collections.map(({ id, title }) => (
<li key={id}>{title}</li>
))}
</ul>
);
}
import { StacApi } from "stac-react";
const stacApi = new StacApi(url);
| Option | Type | Default | Description |
|---|---|---|---|
url | string | Required. The endpoint of the STAC API you want to connect to. |
Retrieves collections from a STAC catalog.
import { useCollections } from "stac-react";
const { collections } = useCollections(stacApi);
| Option | Type | Default | Description |
|---|---|---|---|
stacApi | Instance of StacApi | Required. The STAC API you want to connect to. |
| Option | Type | Description |
|---|---|---|
collections | array | A list of collections available from the STAC catalog. Is null if collections have not been retrieved. |
status | str | The status of the request. "IDLE" before and after the request is sent or received. "LOADING" when the request is in progress. |
reload | function | Callback function to trigger a reload of collections. |
import { StacApi, useCollections } from "stac-react";
function CollectionList() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const { collections, status } = useCollections(stacApi);
if (status === "LOADING") {
return <p>Loading collections...</p>
}
return (
<>
{collections ? (
<ul>
{collections.map(({ id, title }) => (
<li key={id}>{title}</li>
))}
</ul>
<button type="button" onclick={reload}>Update collections</button>
): (
<p>No collections</p>
)}
</>
);
}
Executes a search against a STAC API using the provided search parameters.
import { useStacSearch } from "stac-react";
const { collections } = useStacSearch(stacApi);
| Option | Type | Default | Description |
|---|---|---|---|
stacApi | Instance of StacApi | Required. The STAC API you want to connect to. |
| Option | Type | Description |
|---|---|---|
submit | function | Callback to submit the search using the current filter parameters. Excecutes an API call to the specified STAC API. |
bbox | array<number> | Array of coordinates [northWestLon, northWestLat, southEastLon, southEastLat], undefined if unset. |
setBbox(bbox) | function | Callback to set bbox. bbox must be an array of coordinates [northWestLon, northWestLat, southEastLon, southEastLat], or undefined to reset. |
collections | array<string> | List of select collection IDs included in the search query. undefined if unset. |
setCollections(collectionIDs) | function | Callback to set collections. collectionIDs must be an array of string with the IDs of the selection collections, or undefined to reset. |
dateRangeFrom | string | The from-date of the search query. undefined if unset. |
setDateRangeFrom(fromDate) | function | Callback to set dateRangeFrom. fromDate must be ISO representation of a date, ie. 2022-05-18, or undefined to reset. |
dateRangeTo | string | The to-date of the search query. undefined if unset. |
setDateRangeTo(toDate) | function | Callback to set dateRangeto. toDate must be ISO representation of a date, ie. 2022-05-18, or undefined to reset. |
results | object | The result of the last search query; a GeoJSON FeatureCollection with additional members. undefined if the search request has not been submitted, or if there was an error. |
state | string | The status of the request. "IDLE" before and after the request is sent or received. "LOADING" when the request is in progress. |
error | Error | Error information if the last request was unsuccessful. undefined if the last request was successful. |
nextPage | function | Callback function to load the next page of results. Is undefined if the last page is the currently loaded. |
previousPage | function | Callback function to load the previous page of results. Is undefined if the first page is the currently loaded. |
import { useCallback } from "react";
import { StacApi, useStacSearch } from "stac-react";
import Map from "./map";
function StacComponent() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const { result } = useStacSearch(stacApi);
return (
<>
<div class="item-list">
{results && (
<ul>
{results.features.map(({ id }) => (
<li key={id}>{ id }</li>
))}
</ul>
)}
</div>
</>
)
}
import { useCallback } from "react";
import { StacApi, useStacSearch } from "stac-react";
import Map from "./map";
function StacComponent() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const { error, result } = useStacSearch(stacApi);
return (
<>
<div class="item-list">
{error && <p>{ error.detail }</p>}
{results && (
<ul>
{results.features.map(({ id }) => (
<li key={id}>{ id }</li>
))}
</ul>
)}
</div>
</>
)
}
import { useCallback } from "react";
import { StacApi, useStacSearch } from "stac-react";
import Map from "./map";
function StacComponent() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const {
nextPage,
previousPage,
result
} = useStacSearch(stacApi);
return (
<>
<div class="item-list">
{results && (
// render results
)}
</div>
<div class="pagination">
<button type="button" disabled={!previousPage} onClick={previousPage}>
<button type="button" disabled={!nextPage} onClick={nextPage}>
</div>
</>
)
}
import { useCallback } from "react";
import { StacApi, useStacSearch } from "stac-react";
function StacComponent() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const { collections } = useCollections(stacApi);
const { collections: selectedCollections, setCollections, results, submit } = useStacSearch(stacApi);
const handleChange = useCallback((event) => {
const { value } = event.target;
const nextValues = selectedCollections.includes(value)
? selectedCollections.filter((v) => v !== value)
: [ ...selectedCollections, value ];
setCollections(nextValues);
}, [selectedCollections, setCollections]);
return (
<>
<div class="query-builder">
<form onSubmit={submit}>
<fieldset>
<legend>Select collections</legend>
{collections.map(({ id, title }) => (
<input
id={id}
name="collections"
value={id}
type="checkbox"
onChange={handleChange}
checked={selectedCollections.includes(id)}
/>
<label htmlFor={id}>{title}</label>
))}
<fieldset>
<button type="submit">Search</button>
</form>
</div>
</>
)
}
import { useCallback } from "react";
import { StacApi, useStacSearch } from "stac-react";
import Map from "./map";
function StacComponent() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const { bbox, setBbox, submit } = useStacSearch(stacApi);
const handleDrawComplete = useCallback((feature) => {
setIsBboxDrawEnabled(false);
const { coordinates } = feature.geometry;
const bbox = [...coordinates[0][0], ...coordinates[0][2]];
setBbox(bbox);
}, [setBbox]);
<Map handleDrawComplete={handleDrawComplete} />
}
This example assumes that a Map component handles drawing and calls handleDrawComplete to set the bbox for the search. handleDrawComplete is called with a GeoJSON feature representing the bounding box drawn on the map.
import { useCallback } from "react";
import { StacApi, useStacSearch } from "stac-react";
import Map from "./map";
function StacComponent() {
const stacApi = new StacApi("https://planetarycomputer.microsoft.com/api/stac/v1");
const {
dateRangeFrom,
setDateRangeFrom,
dateRangeTo,
setDateRangeTo,
submit
} = useStacSearch(stacApi);
return (
<>
<input type="date" name="date_from" onChange={setDateRangeFrom} value={dateRangeFrom} />
<input type="date" name="date_to" onChange={setDateRangeTo} value={dateRangeTo} />
<button type="button" onclick={submit}>
</>
)
}
{
detail: "Invalid bbox object"
status: 400,
statusText: "Bad Request"
}
| Option | Type | Description |
|---|---|---|
detail | string | `object |
status | number | HTTP status code of the response. |
statusText | string | Status text for the response. |
FAQs
React components and hooks for building STAC-API front-ends
The npm package @developmentseed/stac-react receives a total of 55 weekly downloads. As such, @developmentseed/stac-react popularity was classified as not popular.
We found that @developmentseed/stac-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.

Security News
n8n led JavaScript Rising Stars 2025 by a wide margin, with workflow platforms seeing the largest growth across categories.

Security News
The U.S. government is rolling back software supply chain mandates, shifting from mandatory SBOMs and attestations to a risk-based approach.