Error: You need to call Parse.initialize before using Parse

Hello! I want to use the usernames of the database as “path” to map the routes of my NEXT JS app. Im fetching an object that contains the usernames of all users registered on my Moralis server using a cloud function that looks like this:

function getUsers() {
  const query = new Parse.Query("User");
  const result = query.find({ useMasterKey: true });
  return result;

Then, in my app component I filter the previous object to obtain only the usernames:

async function getCloud() {
  const cloud = await"cloud");
  return { attributes: { username: any } }) => ({
    params: {
      username: ParseUser.attributes.username

After that, I try to use NEXT’s native function to obtain the username from the params of this object:

export const getStaticPaths: GetStaticPaths = async () => {
  const paths = await getCloud();
  return {
    fallback: false

The getStaticPaths function is throwing the above error but I don’t really know the proper way to initialize parse (as far as Im concerned Moralis is a fork from parse right?) so I think maybe you know better than me about this issue. Any help will be much appreciated!

I think that you need to initialize Moralis first with app ID and server url

Thank you @cryptokid I have already done so inside my _app.tsx file:

function MyApp({ Component, pageProps }: AppProps) {
  return (
    <MoralisProvider appId={appId} serverUrl={serverUrl}>

is there any reason the cloud JS function is not able to get the initialized Moralis server?

I don’t know exactly how that syntax with MoralisProvider works, this is what I do sometimes:

import { Moralis } from "moralis";

const appId = "APP_ID";
const serverUrl = "SERVER_URL";

Moralis.serverURL = serverUrl;

But it should be possible to do something as what you are trying to do with MoralisProvider.

1 Like

By using context hook, MoralisProvider passes ‘APP_ID’ and ‘SERVER_URL’ to all its child components.