Next.js app and query lambdas

If I want to execute a query lambda on my next.js app, I can just put it in my API directory on my next.js app?

Yeah, exactly, that’s what you would do. You can have something like this:

import rockset from '@rockset/client';

export default (req, res) => {
  const ApiKey = process.env.ROCKSET_APIKEY;
  const rocksetClient = rockset(ApiKey);
  
return rocksetClient.queryLambdas
    .executeQueryLambda('commons', 'YOUR QUERY LAMBDA', 'SOME HASH', null)
    .then((response) => {
      res.status(200).json(response.results);
    });
};