Instagram has been growing like crazy over the past few years, and one of its key features that fueled that growth was the famous photo filters. By allowing users to apply various filters to their photos to make them better looking, Instagram has created an amazing product. Any modern photo app must support photo filters nowadays, so we are going to take a look at how to implement the Instagram photo filters in React Native. In today’s article we’re going to be talking about how to implement the Instagram photo filters. We’re going to use the package react-native-image-filter-kit . Here at Instamobile we use this library to seamlessly build this photo filters feature into our Instagram Clone . Implementing Instagram Photo Filters in React Native First of all, let’s install the package we mentioned earlier into your React Native project, by running: npm install -s react-native-image-filter-kit Here’s a simple React Native project that applies the Instagram photo filters to an image included in the codebase (the image name is “parrot.png”, so make sure you include it in your project folder, so that it can be loaded in the app). In the App.js file, simply place the following code snippet: React ; {Image, SafeAreaView} ; {Emboss} ; App = ( <SafeAreaView /> <Image style={styles.image} source={require('./parrot.png')} resizeMode={'contain'} /> <Emboss image={ <Image style={styles.image} source={require('./parrot.png')} resizeMode={'contain'} /> } /> </> ); const styles = { image: { width: 320, height: 320, marginVertical: 10, alignSelf: 'center', }, }; import from 'react' import from 'react-native' import from 'react-native-image-filter-kit' const => () <> The Emboss component provided by the react-native-filter-kit takes an Image component as a prop and applies the filter as seen in the below screenshot. There are a ton of other filter components provided by the library react-native-image-filter-kit so we are going to find a way to implement a more comprehensive filter just like the way it is done in the Instagram app itself. First of all we need to define an array of filter components that we are going to render and select from: { AdenCompat, _1977Compat, BrannanCompat, BrooklynCompat, ClarendonCompat, EarlybirdCompat, GinghamCompat, HudsonCompat, InkwellCompat, KelvinCompat, LarkCompat, LofiCompat, MavenCompat, MayfairCompat, MoonCompat, NashvilleCompat, PerpetuaCompat, ReyesCompat, RiseCompat, SlumberCompat, StinsonCompat, ToasterCompat, ValenciaCompat, WaldenCompat, WillowCompat, Xpro2Compat, } ; FILTERS = [ { : , : AdenCompat, }, { : , : MavenCompat, }, { : , : MayfairCompat, }, { : , : MoonCompat, }, { : , : NashvilleCompat, }, { : , : PerpetuaCompat, }, { : , : ReyesCompat, }, { : , : RiseCompat, }, { : , : SlumberCompat, }, { : , : StinsonCompat, }, { : , : BrooklynCompat, }, { : , : EarlybirdCompat, }, { : , : ClarendonCompat, }, { : , : GinghamCompat, }, { : , : HudsonCompat, }, { : , : InkwellCompat, }, { : , : KelvinCompat, }, { : , : LarkCompat, }, { : , : LofiCompat, }, { : , : ToasterCompat, }, { : , : ValenciaCompat, }, { : , : WaldenCompat, }, { : , : WillowCompat, }, { : , : Xpro2Compat, }, { : , : AdenCompat, }, { : , : _1977Compat, }, { : , : BrannanCompat, }, ]; import from 'react-native-image-filter-kit' const title 'Normal' filterComponent title 'Maven' filterComponent title 'Mayfair' filterComponent title 'Moon' filterComponent title 'Nashville' filterComponent title 'Perpetua' filterComponent title 'Reyes' filterComponent title 'Rise' filterComponent title 'Slumber' filterComponent title 'Stinson' filterComponent title 'Brooklyn' filterComponent title 'Earlybird' filterComponent title 'Clarendon' filterComponent title 'Gingham' filterComponent title 'Hudson' filterComponent title 'Inkwell' filterComponent title 'Kelvin' filterComponent title 'Lark' filterComponent title 'Lofi' filterComponent title 'Toaster' filterComponent title 'Valencia' filterComponent title 'Walden' filterComponent title 'Willow' filterComponent title 'Xpro2' filterComponent title 'Aden' filterComponent title '_1977' filterComponent title 'Brannan' filterComponent Next, we have to render a horizontal list of filters at the bottom and dynamically change the filter image as the center image when a filter is selected. Your App.js file will then become: React, {useRef, useState} ; { FlatList, Image, SafeAreaView, StyleSheet, Text, TouchableOpacity, } ; App = { extractedUri = useRef( ); [selectedFilterIndex, setIndex] = useState( ); onExtractImage = { extractedUri.current = nativeEvent.uri; }; onSelectFilter = { setIndex(selectedIndex); }; renderFilterComponent = { FilterComponent = item.filterComponent; image = ( <TouchableOpacity onPress={() => onSelectFilter(index)}> <Text style={styles.filterTitle}>{item.title}</Text> <FilterComponent image={image} /> </TouchableOpacity> ); }; const SelectedFilterComponent = FILTERS[selectedFilterIndex].filterComponent; return ( <> <SafeAreaView /> {selectedFilterIndex === 0 ? ( <Image style={styles.image} source={require('./car.jpg')} resizeMode={'contain'} /> ) : ( <SelectedFilterComponent onExtractImage={onExtractImage} extractImageEnabled={true} image={ <Image style={styles.image} source={require('./car.jpg')} resizeMode={'contain'} /> } /> )} <FlatList data={FILTERS} keyExtractor={item => item.title} horizontal={true} renderItem={renderFilterComponent} /> </> ); }; const styles = StyleSheet.create({ image: { width: 520, height: 520, marginVertical: 10, alignSelf: 'center', }, filterSelector: { width: 100, height: 100, margin: 5, }, filterTitle: { fontSize: 12, textAlign: 'center', }, }); import from 'react' import from 'react-native' const => () const 'https://www.hyundai.com/content/hyundai/ww/data/news/data/2021/0000016609/image/newsroom-0112-photo-1-2021elantranline-1120x745.jpg' const 0 const ( ) => {nativeEvent} const => selectedIndex const ( ) => {item, index} const const ); return ( < = = ' / ')} = ' '} /> Image style {styles.filterSelector} source {require( . car.jpg resizeMode { contain This source code will produce a simple React Native app that supports selecting various Instagram photo filters, just like the real Instagram photo editor: After selection, the handler method onExtractImage saves the URL of the extracted image after the filter has been selected on the variable extractedUri ref which you could save on your server. Conclusion Now that we have learned how to implement Instagram filters you should check out our Instagram Clone template , which is a fully functional codebase, supporting most of the Instagram features, such as photo filters, ephemeral stories and post feeds. Previously published at https://www.instamobile.io/react-native-tutorials/instagram-photo-filters-react-native/