This work utilizes the particle swarm optimization (PSO) for optimal sizing of a solar–wind–battery hybrid renewable energy system (HRES) for a rural community in Rivers State, Nigeria (Okorobo-Ile Town). The objective is to minimize the total economic cost (TEC), the total annual system cost (TAC) and the levelized cost of energy (LCOE). A two-step approach is used. The algorithm first determines the optimal number of solar panels and wind turbines. Based on the results obtained in the first step, the optimal number of batteries and inverters is computed. The overall results obtained are then compared with results from the Non-dominant Sorting Genetic Algorithm II (NGSA-II), hybrid genetic algorithm–particle swarm optimization (GA-PSO) and the proprietary derivative-free optimization algorithm. An energy management system monitors the energy balance and ensures that the load management is adequate using the battery state of charge as a control strategy. Results obtained showed that the optimal configuration consists of solar panels (151), wind turbine (3), inverter (122) and batteries (31). This results in a minimized TEC, TAC and LCOE of USD 469,200, USD 297,100 and 0.007/kWh, respectively. The optimal configuration when simulated under various climatic scenarios was able to meet the energy needs of the community irrespective of ambient conditions.